title: handling nodeJs input from console?
body: <p>I am still new to nodeJs, and I am trying to create a stream of inputs but my code is not working once I launch the app in the terminal by calling node fileName .</p>
  
  <p>My input format is like this:</p>
  
  <pre><code>- N the number of queries.
  - second line represent a string containing two words separated by a space.
  - N lines of a string containing two words separated by a space.
  </code></pre>
  
  <p>for some reason, the terminal doesn't show a thing.</p>
  
  <p>This is my code : </p>
  
  <pre><code>'use strict';
  const fs = require('fs');
  var n = 0;
  var position = '';
  var destination = '';
  var array = [];
  
  
  process.stdin.resume();
  process.stdin.setEncoding('utf-8');
  
  let inputString = '';
  let currentLine = 0;
  
  process.stdin.on('data', inputStdin =&gt; {
      inputString += inputStdin;
  });
  
  process.stdin.on('end', _ =&gt; {
      inputString = inputString.replace(/\s*$/, '')
          .split('\n')
          .map(str =&gt; str.replace(/\s*$/, ''));
  
      main();
  });
  
  function readLine() {
      return inputString[currentLine++];
  }
  function main() {
      const ws = fs.createWriteStream(process.env.OUTPUT_PATH);
  
  
      const s =  parseInt(readLine(), 10);
  
      const input= readLine().split(' ');
  
      position = input[0] ;
      destination = input[1];
  
      console.log('our number is',s, 'and our position and destination:', position, destination);
  
      ws.end();
  }
  </code></pre>