title: Getting values from stdin with Node.js & TypeScript
body: <p>I have some tasks, basically a CLI script that takes x lines, and based on said lines makes some calculations.</p>
  
  <p>Eg.:</p>
  
  <p>Input:</p>
  
  <pre><code>3 // number of iterations to do something
  ATCCGCTTAGAGGGATT // first string
  GTCCGTTTAGAAGGTTT // second string
  // 2nd iteration starts
  abcdefghijklmnopqrstuvwxyz
  bcdefghijklmnopqrstuvwxyza
  // 3rd iteration starts
  abcdefghijklmnopqrstuvwxyz0123456789
  abcdefghijklmnopqrstuvwxyz0123456789
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>ATCCGCTTAGAGGGATT // first string
  GTCCGTTTAGAAGGTTT // second string
  *....*.....*..*.. // visual marker of differences between the two strings(*)
  
  abcdefghijklmnopqrstuvwxyz
  bcdefghijklmnopqrstuvwxyza
  **************************
  
  abcdefghijklmnopqrstuvwxyz0123456789
  abcdefghijklmnopqrstuvwxyz0123456789
  ....................................
  </code></pre>
  
  <p>What i've tried:</p>
  
  <pre><code>const rl = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    prompt: ''
  })
  
  let numberOfTests = 0;
  let firstText = '';
  let secondText = '';
  let differences = '';
  
  rl.prompt();
  
  rl.on('line', (line: any) =&gt; {
    let loop = 0;
    numberOfTests = line;
    firstText = line;
    secondText = line;
    calculateDifferences(firstText, secondText); // basic function that loops through the arrays and makes the visual marker.
    loop ++;
    if (loop === numberOfTests) {
      rl.close();
    }
  }).on('close', () =&gt; {
    console.log('Have a great day!');
    process.exit(0);
  });
  </code></pre>
  
  <p>The main issue I am facing is that i cannot separate the input stream from one another.
  By the time we are at the secondText every variable will be equal to wheter I input on the 3rd time.</p>
  
  <p>How can you separate the inputs from each other?</p>
  
  <p><a href="https://nodejs.org/api/readline.html#readline_readline" rel="nofollow noreferrer">Node documentation</a> is not so detailed about this.Or I cannot see it through correctly.</p>