title: Write to specific line on file
body: <p>I want to be able to write to a file and always write at that line.</p>
  
  <pre><code>1 Hello
  2 How are you
  3 Good
  4 I see
  5 Banana
  6 End
  </code></pre>
  
  <p>Using a function:</p>
  
  <pre><code>function filewriter($filename, $line, $text,$append) {
  }
  </code></pre>
  
  <p>So append = add without overwriting the line and that's optional as it will default to append</p>
  
  <p>so append:</p>
  
  <pre><code>filewriter ("bob.txt", 2, "Bobishere", true) or filewriter ("bob.txt", 2, "Bobishere") 
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>1 Hello
  2 Bobishere
  3 How are you
  4 Good
  5 I see
  6 Banana
  7 End
  </code></pre>
  
  <p>but if they don't append it looks like this:
    filewriter ("bob.txt", 2, "Bobishere", false)</p>
  
  <p>output:</p>
  
  <pre><code>1 Hello
  2 Bobishere
  3 Good
  4 I see
  5 Banana
  6 End
  </code></pre>
  
  <p>I've only managed to figure out how to overwrite the file or add to the end of the document.</p>
  
  <p>What the function looks like currently:</p>
  
  <pre><code>function filewriter($filename,$line,$text,$append){
    $current = file_get_contents($filename);
    if ($append)
     $current .= $line;
    else
     $current = $line;
    file_put_contents($file, $current);
  }
  </code></pre>