Paste the code directly:
const readline = require('readline')
//Readline is a packaged module that implements standard input and output in Node.js. Through this module, we can read the data stream line by line. Modules can be referenced using require("readline").
const r1 = readline.createInterface({
input: fs.createReadStream("data.txt")
});
var i = 1; //Number of lines in txt
r1.on('line', function(line){ //Event listener
console.log('Line from file:' + i + ":" + line);
if (i == 1){
console.log(line)
}
i+=1;
})
This operation is performed asynchronously,