title: Read newest csv records with Node
body: <p>I'd like to watch a CSV file and get the newest records since it was changed. I'm running the following shell command to build a very simple csv file and append a new line every second:</p>
  
  <p><code>rm test.csv &amp; x=0 &amp;&amp; while true; do echo "${x},${x},${x}" &gt;&gt; test.csv; x=$(($x+1)); sleep 1; done</code></p>
  
  <p>The following code prints all the records of the file until the first change and then just emits the dashed line, as if it's not re-reading the file:</p>
  
  <pre><code>'use strict';
  
  var fs = require('fs'),
      dataFile = __dirname + '/server/data/test.csv',
      csv = require('csv');
  
  var parser = csv.parse({delimiter: ','}, function(err, data){
      console.log(data);
  });
  
  var watcher = fs.watch(dataFile);
  watcher.on('change', fileChange);
  
  function fileChange(e, fn){
      if (e) console.error(e)
  
      fs.createReadStream(dataFile).pipe(parser);
      console.log('-------')
  }
  </code></pre>
  
  <p>Shouldn't the <code>fileChange</code> function re-read the file on every change? My ultimate plan here is to get both the previous array of lines and the current one and use lodash's <code>difference</code> function to return only the differences. If there's better way, I'm open to hear it though.</p>