title: Ruby File IO question; Maintain file read position between script executions
body: <p>I have two files <code>a.txt</code> and <code>b.txt</code> (henceforth <code>a</code> and <code>b</code>).</p>
  
  <p>My script iterates through <code>a</code>, does some operation, and <strong>potentially</strong> inserts a line to <code>b</code>.</p>
  
  <p>In the event the script stops, I need it to pick up where it left off. In the example below:</p>
  
  <ol>
  <li>foo was copied to <code>b</code></li>
  <li>bar was copied to <code>b</code></li>
  <li>zim was <strong>not</strong> copied to <code>b</code> (did not pass some criteria)</li>
  <li>gaz was copied to <code>b</code></li>
  <li>Script stops (for whatever reason)</li>
  </ol>
  
  <p>When script starts again, how to open <code>a</code> and start on line <code>"dib"</code>?</p>
  
  <h2>a.txt</h2>
  
  <pre><code>foo
  bar
  zim
  gaz      // &lt;= last successful copy
  dib      // &lt;= I want to start here on next script execution
  gir
  </code></pre>
  
  <h2>b.txt</h2>
  
  <pre><code>foo
  bar
  gaz      // &lt;= note omission of "zim" above gaz
  </code></pre>
  
  <hr>
  
  <h2>Note:</h2>
  
  <p><code>a.txt</code> is almost 1,000,000 lines</p>