If you look at the source for the lineno=
method, you'll see that it doesn't affect the input stream in any way - it just overwrites the automatic line number with the given value. If you want to skip to a certain line you'll need to write your own method.
Note that files are stored as sequences of bytes, not as lines. To skip to a specific line you need to scan the file for line separators.
For example:
def ARGF.skip_lines num
enum = each_line
num.times { enum.next }
self
end
I tested this with a 36M file with 600,000 lines and it could skip from the first to last line in about 1 second.
If you have control over the input format, you could pad each line to a specific length and then use IO#seek
to jump to a certain one. But that has other downsides.