title: File.ReadLines throws OutOfMemoryException
body: <p>I have a strange issue that I can't seem to find a solution for.
  I'm trying to read large files (from 500Mb up to 2Gb) by chunks of 8M lines.</p>
  
  <p>For that, I created the following:</p>
  
  <pre><code>public static List&lt;string&gt; read_file(string path, Int32 start, Int32 end, Boolean is_big_file)
  {
      try
      {
          List&lt;string&gt; lines = new List&lt;string&gt;();
  
          if (is_big_file)
              lines = File.ReadLines(path).Skip(start).Take(end - start).ToList();
          else
              lines = File.ReadAllLines(path).ToList();
  
          return lines;
      }
      catch { return null; }
  }
  </code></pre>
  
  <p>If the file has less than 8M lines, ReadAllLines is used and everything works.
  If the file is more than that, it will use ReadLines.Skip.Take.</p>
  
  <p>The first chunk works, I receive the first 8 M lines.
  start = 0. end = 8,000,000.</p>
  
  <p>The second chunk doesn't work. 
  start = 8,000,000. end = 16,000,000 or the last line of the file (depending on the number of lines). 
  For some reason, I get OutOfMemoryException when I have less than 8M lines to read (end = 12,500,000).</p>
  
  <p>Do you have any idea why it happens? Does Skip caches the original lines as well?
  Is there a more elegant solution for it?</p>
  
  <p>Thanks!</p>