title: How to use readline in NodeJs on an event (wait stream close)
body: <p>I'm creating a bot that when it receives a message begins to read a text file and responds to the message with the contents of the file.</p>
  
  <p>Unfortunately, I can't get out of this asynchronous hell and I only get errors, undefined or promise </p>
  
  <p>The last experiment was this:</p>
  
  <pre><code>const fs = require('fs');
  const readline = require('readline');
  
  // bot.listen("message").reply(responseText())
  
  function readFile(file) {
      var text = '';
          var readInterface = readline.createInterface({
              input: fs.createReadStream(file),
              terminal: false
          });
  
          readInterface.on('line', function(line) {
              linea = line.trim();
              console.log(linea);
              text += linea;
          }).on('close', function() {
              return text;
          });
      });
  }
  
  async function responseText() {
      var content = await readFile("file.txt");
      content.then(function(data) {
          return data;
      })
  }
  </code></pre>
  
  <p>What I would like to get then is delay the response until I get the contents of the file. 
  I know that node is based on async but I can't figure out how to handle it!</p>
  
  <p>Thanks all</p>