Read last line of a large file with NodeJs
<p>I'm using <a href="https://coderwall.com/p/ohjerg/read-large-text-files-in-nodejs" rel="nofollow">this example</a> to read a large file:      </p>

<pre><code>var fs = require('fs');
var readline = require('readline');
var stream = require('stream');

var instream = fs.createReadStream('your/file');
var outstream = new stream;
var rl = readline.createInterface(instream, outstream);

rl.on('line', function(line) {
  // process line here
});

rl.on('close', function() {
  // do something on finish here
});
</code></pre>

<p>And I want to know when <code>line</code> is the last line of file. I read the <a href="https://nodejs.org/api/readline.html" rel="nofollow">docs</a> but can not find a solution. I already tried:</p>

<pre><code>rl.on('line', function(line) {
    if (line == '' || line == require("os").EOL)
        console.log('eof');        
});
</code></pre>

<p>but it didnt work.<br>
Do you have any suggestions. Thanks for reading.</p>