I use the following code to read the file line by line. But the content of the line is in a closure, what can I do to access the contents of the line outside?The module I am using is the internal module of node.js
var fs=require("fs")
function readFirstLine(){
var firstfile = [];
readline = require('readline');
var rd = readline.createInterface({
input: fs.createReadStream('somefile.txt'),
output: process.stdout,
terminal: false
});
rd.on('line', function(line) {
console.log(line)
}
);
}
readFirstLine()