Read a file one line at a time in node.js?
Since Node.js v0.12 and as of Node.js v4.0.0, there is a stable readline core module. Here’s the easiest way to read lines from a file, without any external modules: const fs = require(‘fs’); const readline = require(‘readline’); async function processLineByLine() { const fileStream = fs.createReadStream(‘input.txt’); const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity }); // … Read more