Skip to content

Instantly share code, notes, and snippets.

@yannisxu
Created December 4, 2014 17:17
Show Gist options
  • Save yannisxu/2ef272069d84ac0289be to your computer and use it in GitHub Desktop.
Save yannisxu/2ef272069d84ac0289be to your computer and use it in GitHub Desktop.
read file line by line in nodejs
var fs = require('fs'),
readline = require('readline');
var rd = readline.createInterface({
input: fs.createReadStream('demo.txt'),
output: process.stdout,
terminal: false
});
rd.on('line', function(line) {
console.log(line);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment