title: Appending one string to another, but appendage is on new line not same line
body: <p>I am appending something to each line in a file and then writing that to a new file. </p>
  
  <p>But when I looked at the new file what it is doing is writing the line from the old file then writing what it should be appending to that line on a new line.</p>
  
  <p>So if the first line in the old file is</p>
  
  <pre><code>A
  </code></pre>
  
  <p>The first and second line in the new file is</p>
  
  <pre><code>A
  /appendage
  </code></pre>
  
  <p>What it should be is one line:</p>
  
  <pre><code>A /appendage
  </code></pre>
  
  <p>How can I fix my code so that the appendages are on the same line as what they are being appended to?</p>
  
  <pre><code>function writeTag($tags, $line, $file){
      foreach($tags as $t){
          $line .= " /".$t['tag']." ";
          fwrite($file, $line);
      }
  }
  $tagger = new PosTagger('lexicon.txt');
  $lines = file('dictionary.txt');
  $out = fopen("tagged.txt", "w");
  foreach($lines as $line){
      $tags = $tagger-&gt;tag($line);
      writeTag($tags, $line, $out);
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>With bwoebi's updated answer adding IGNORE_NEW_LINES, the output file I am getting looks like:</p>
  
  <pre><code>A /DT A$ /DT A&amp;E /DT A&amp;E /DT  /NN A&amp;M /DT A&amp;M /DT  /NN
  A&amp;P /DT A&amp;P /DT  /NN
  </code></pre>
  
  <p>What I am looking for is:</p>
  
  <pre><code>A /DT
  A$ /DT
  A&amp;E /DT
  A&amp;E /DT /NN
  A&amp;M /DT
  A&amp;M /DT /NN
  A&amp;P /DT
  A&amp;P /DT /NN
  </code></pre>