how to read a file line by line in nodejs code example
Example: node.js read text file line by line
const readline = require('readline');
const readInterface = readline.createInterface({
input: fs.createReadStream('name.txt'),
output: process.stdout,
console: false
});
for await (const line of readInterface) {
console.log(line);
}
//or
readInterface.on('line', function(line) {
console.log(line);
});