title: How do I use readline in Node.js to get all input lines into an array?
body: <p>I'd like to create a convenience function that does something like this for the purposes of CodeAbbey:</p>
  
  <pre><code>var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
  });
  
  var lines = [];
  
  rl.on('line', (line) =&gt; {
    lines.push(line);
  });
  
  return lines;
  </code></pre>
  
  <p>However, because of how <code>readline</code> functions as an event handler of course all I get back is an empty array.</p>
  
  <p>How do I get readline to carry out the desired behavior here? Or do I use some other library? I'd rather just use "default" components but if I have to use something else I will.</p>