Skip to main content

Mike Kreuzer

Read a file one line at time using Node

September 13, 2015

I found some better code on the StrongLoop site for reading a file one line at a time in Node.

It's something that should be in any scripting environment's standard library, but isn't in Node's, so before I lose the link, the StrongLoop article's here and and that code as a gist is here.

Drop that module into your Node project, usage is then:

var readFileByLine = require('./readFileByLine');

function yourFunctionUsingOneLine(line) {

readFileByLine('yourFile', yourFunctionUsingOneLine);