title: Is there a way to seek through a file without loading the whole thing into an array?
body: <p>This works:</p>
  
  <pre><code>f = File.new("myfile").readlines
  f[0] #=&gt; "line 1"
  f[21] #=&gt; "line 22"
  </code></pre>
  
  <p>But what if I have a very large file, and only need to read a few lines. Is it possible to seek to specific lines and read them in Ruby, without loading the file into an array?</p>
  
  <p>I grok IO streams, where (as in the case of stdin) you can't randomly seek through a stream. Surely there must be a way to do this without loading the entire file.</p>