title: SplFileObject iteration duplicates key 0
body: <p>All,</p>
  
  <p>I cannot for the life of me, figure out why <code>\SplFileObject</code> is repeating the key in the following code. This sample uses Nowdoc as a file stream but this effect can be noted using any file.</p>
  
  <p>PHP Code:</p>
  
  <pre><code>$str = &lt;&lt;&lt;'EOD'
  Line 1
  Line 2
  Line 3
  Line 4
  Line 5
  EOD;
  
  $file = new \SplFileObject('data://text/plain;base64,' . base64_encode($str));
  $iterator = call_user_func(function (\SplFileObject $file) {
    while (!$file-&gt;eof()) {
      yield [$file-&gt;key() =&gt; $file-&gt;fgets()];
    }
  }, $file);
  
  foreach ($iterator as $line) {
    echo key($line) . ': ' . current($line) . PHP_EOL;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>0: Line 1
  0: Line 2
  1: Line 3
  2: Line 4
  3: Line 5
  </code></pre>