title: nodejs - writeFile creates empty file
body: <p>I'm trying to write my puppeteer result to a txt, but i cant make it work. The txt is created, but empty</p>
  
  <p>I'm using process.exit, but dont know if it is the correct way</p>
  
  <p>I know textContent is not empty, cause i can console log its content</p>
  
  <pre><code>var https = require('https');
  var Q = require('q');
  var fs = require('fs');
  var puppeteer = require('puppeteer');
  
  const url = 'https://www.99freelas.com.br/projects'
  /*const idToScrape;
  deverá receber qual a url e os parametros específicos dela */
  async function genScraper() {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
  
      await page.goto(url);
  
      var textContent = await page.evaluate(() =&gt; {
          const ali = Array.from(document.querySelectorAll('.result-list li'));
          return ali.map(li =&gt; li.textContent)
      });
  
      fs.writeFile('res.txt', textContent, (err) =&gt; {
          if (err) throw err;
      });
  
      const innerText = await page.evaluate(() =&gt; {
          const ali = Array.from(document.querySelectorAll('.result-list li'));
          return ali.map(li =&gt; li.innerText);
      });
  
  
      process.exit();
  }
  //not used
  function gravaArquivo(arquivo) {
      var deferido = Q.defer();
      fs.writeFileSync('resultado.txt', arquivo, function(err) {
          deferido.resolve(true);
          console.log('aqui estou')
      });
      return deferido.promise;
  }
  
  genScraper();
  </code></pre>