Reading a file line by line

suggest change

app.js

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

var file = 'path.to.file';
var rl = readline.createInterface({
    input: fs.createReadStream(file),
    output: process.stdout,
    terminal: false
});

rl.on('line', function (line) {
    console.log(line) // print the content of the line on each linebreak
});

Usage:

node app

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents