$readn will return the last line number that was read, this can be used with $calc and additional calls to $read(file,n) to get what you want.