title: Express: Download returns empty file
body: <p>Whenever I'm hitting the endpoint, I keep getting empty file while locally generated file is correct and contains all the fields I need. I've tried piping directly to response but I would be getting:</p>
  
  <blockquote>
    <p>Cannot pipe, not readable</p>
  </blockquote>
  
  <p>Of course there might be something I'm doing wrong. </p>
  
  <p><a href="https://stackoverflow.com/questions/47311108/download-returning-empty-file?rq=1">Similar question.</a> </p>
  
  <pre><code>const PORT = 3000;
  
  const express = require('express');
  const fs = require('fs');
  const csv = require('fast-csv');
  
  const app = express();
  
  app.listen(PORT, () =&gt; {
  console.log(`Express server is listening on ${PORT}`);
  });
  
  app.get('/rates/csv', (req, res) =&gt; {
  
  let ws = fs.createWriteStream(__dirname + '/tmp/rates.csv');
  
  csv.write([
      ["a", "b"],
      ["a1", "b1"],
      ["a2", "b2"]
  ], {headers: true})
      .pipe(ws);
  
  console.log('FILE SAVED');
  
  res.download(ws.path, 'rates.csv')
  });
  </code></pre>