var readline = require('readline');
var fs = require('fs');

var myInterface = readline.createInterface({
  input: fs.createReadStream('demofile1.html')
});

var lineno = 0;
myInterface.on('line', function (line) {
  lineno++;
  console.log('Line number ' + lineno + ': ' + line);
});

              
Line number 1: <!DOCTYPE html>
Line number 2: <html>
Line number 3: <title>Demo - Open file</title>
Line number 4: <body>
Line number 5: <h1>My Header</h1>
Line number 6: <p>My paragraph</p>
Line number 7: </body>
Line number 8: </html>