Keep in mind that because "lines" are of variable length, there is no way to simply jump to line 1000 without first sifting through the file line by line to determine where line 1000 begins in the file. So any solution you come up with (short of maintaining an index or requiring uniform-length lines) will require that the file be read at least once, at least until the proper line number is finally found.
But you don't have to slurp the whole file into an array. It's fine to just read line by line, and take action when the desired line number is found.