Created
March 31, 2017 21:34
-
-
Save akirattii/afa4da30ac5412beac33fc02bee63fb3 to your computer and use it in GitHub Desktop.
Read and write every line of input.txt into output.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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