title: Node.js, Using single readline to read multiple files
body: <p>After learning Ruby on Rails I wanted also learn Node.JS.</p>
  
  <p>In Node.JS you can read files line by line by using <code>readline</code>:</p>
  
  <pre><code>var fs = require("fs");
  var readline = require("readline");
  
  var fileName =  "input.txt";
  </code></pre>
  
  <p>We can assign <code>readline</code> to file in this way:</p>
  
  <pre><code>var lineReader = readline.createInterface({
    input: fs.createReadStream(fileName)
  });
  </code></pre>
  
  <p>Then we can read each line like this:</p>
  
  <pre><code>lineReader.on('line', function(line) {
     // handle line code here
  });
  </code></pre>
  
  <p>This will allow me to read only single file. </p>
  
  <p>If I have array of filenames like this:</p>
  
  <pre><code>var fileNames = ["input1.txt", "input2.txt", "input3.txt"];
  </code></pre>
  
  <p>I want to read each lines of each files in this array and handle their <code>line</code> events.</p>
  
  <p>How is it possible to read line by line multiple files? </p>