title: Write to file using SplFileObject()
body: <p>I'm trying to edit a file by line using SplFileObject(). I can choose the line of the file I want to edit. But how do I then write a $string to that line?</p>
  
  <p>Here is my code to get the line:</p>
  
  <pre><code>&lt;?php
  $file = new SplFileObject('myfile.txt');
  $file-&gt;seek(9999);     // Seek to line no. 10,000
  echo $file-&gt;current(); // Print contents of that line
  ?&gt;
  </code></pre>
  
  <p>How do I insert a string on that line?</p>
  
  <p>Note, I don't want to overwrite the file, I simply want to insert a $string at a given line.</p>