Unfortunately, unless you can guarantee that every line in the file is the exact same length, you're going to have to read through the whole file, or at least up to the line you're after.
The only way you can count the lines is to look for the new line characters in the file, and this means you're going to have to read each byte.
It will be possible to optimise your code to make it neat and readable, but underneath you'll always be reading the whole file.
If you're going to reading the same file over and over again you could parse the file and create an index storing the offsets of certain line numbers, for example the byte count of where lines 100, 200 and so on are.