title: PHP script gets progressively slower (file reader)
body: <p>I have a script that, when put against a timer, gets progressively slower.  It's fairly simple as all it does is reads a line, checks it then adds it to the database, then proceeds to the next line.</p>
  
  <p>Here's the output of it gradually getting worse:</p>
  
  <pre><code>Record: #1,001 Memory: 1,355,360kb taking 1.84s
  Record: #1,001 Memory: 1,355,360kb taking 1.84s
  Record: #2,002 Memory: 1,355,192kb taking 2.12s
  Record: #3,003 Memory: 1,355,192kb taking 2.39s
  Record: #4,004 Memory: 1,355,192kb taking 2.65s
  Record: #5,005 Memory: 1,355,200kb taking 2.94s
  Record: #6,006 Memory: 1,355,376kb taking 3.28s
  Record: #7,007 Memory: 1,355,176kb taking 3.56s
  Record: #8,008 Memory: 1,355,408kb taking 3.81s
  Record: #9,009 Memory: 1,355,464kb taking 4.07s
  Record: #10,010 Memory: 1,355,392kb taking 4.32s
  Record: #11,011 Memory: 1,355,352kb taking 4.63s
  Record: #12,012 Memory: 1,355,376kb taking 4.90s
  Record: #13,013 Memory: 1,355,200kb taking 5.14s
  Record: #14,014 Memory: 1,355,184kb taking 5.43s
  Record: #15,015 Memory: 1,355,344kb taking 5.72s
  </code></pre>
  
  <p>The file, unfortunately, is around ~20gb so I'll probably be dead by the time the whole thing is read at the rate of increase.  The code is (mainly) below but I suspect it's something to do with fgets() , but I am not sure what.</p>
  
  <pre><code>    $handle = fopen ($import_file, 'r');
  
      while ($line = fgets ($handle))
      {
          $data = json_decode ($line);
  
          save_record ($data, $line);
      }
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Commenting out 'save_record ($data, $line);' appears to do nothing.</p>