Check for End of File in Nodejs with line by line read
As per node documentation, use close
event
rd.on('line', function(line) {
console.log(line);
})
.on('close', function(line) {
// EOF
});
you can listen to close
event to detect end of file
rd.on('close', function() {
// end of file
})