title: Reading file with fgets() leaves new line character at the end of each line
body: <p>When I explode the lines of a <code>.csv</code> file with a tab as delimiter, like such:</p>
  
  <pre><code>// $handle = some TSV file
  while (($line = fgets($handle)) !== false) {
      $fields = explode("\t",$line);
  }
  </code></pre>
  
  <p>If the last column of the row is empty (or maybe even if it isn't), for some reason the last element in <code>$fields</code> will contain a newline (<code>\n</code>). This is causing problems and I can't quite figure out why it does this, and if it is normal, how to compensate for it.</p>
  
  <p>The csv file is typical like so:</p>
  
  <pre><code>col1\tcol2\tcol3\n
  col1\tcol2\tcol3\n
  ...
  </code></pre>
  
  <p>*The \t and \n are real tabs and new lines in the file.</p>
  
  <p>So in this instance, if col3 was empty, my issue would persist. It might even do so if it isn't empty.</p>
  
  <p><strong>NOTE:</strong> The issue is that I am inserting each of the columns into a MySQL database and the last column has a newline in it. When I export this database back to CSV, it breaks the layout of the file.</p>
  
  <p>So now my question(s) are:</p>
  
  <ol>
  <li><p>Is this normal behavior?</p></li>
  <li><p>If so, what can I do about it if I can't have a newline in the last $field? </p></li>
  </ol>