Skip to content

Instantly share code, notes, and snippets.

@akirattii
Created March 31, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akirattii/afa4da30ac5412beac33fc02bee63fb3 to your computer and use it in GitHub Desktop.
Save akirattii/afa4da30ac5412beac33fc02bee63fb3 to your computer and use it in GitHub Desktop.
Read and write every line of input.txt into output.txt
/*
* Read and write every line of input.txt into output.txt
*/
const fs = require("fs");
var writeStream = fs.createWriteStream("output.txt");
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream("input.txt")
});
lineReader.on('line', function(line) {
writeStream.write(`${line}\n`);
});
lineReader.on('close', function(line) {
writeStream.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment