title: How to read line by line and detect eof (end of file)?
body: <p>Followup to a solution to reading a file line by line, as described here: <a href="https://stackoverflow.com/a/16013228/570796">https://stackoverflow.com/a/16013228/570796</a></p>
  
  <hr>
  
  <pre><code>var fs       = require('fs'),
      readline = require('readline'),
      instream = fs.createReadStream('/path/to/file');
  
  var rl = readline.createInterface(
  {
      input: instream,
      terminal: false
  });
  
  rl.on('line', function(line) 
  {
      console.log(line);
      // if(instream.isEnd()) ...
  });
  </code></pre>
  
  <hr>
  
  <p><strong>How do I detect if I reached the end of the file?</strong></p>
  
  <p>I understand that there is an event on the <code>ReadStream</code> <code>on('end', () =&gt; {/*...*/})</code> But I need a solution where I can check it through an if statement.</p>