title: Piping got.stream to a file
body: <p>I am refactoring some code that was using <code>http</code> module in Node to use <code>got</code> instead. I tried the following:</p>
  <pre><code>function get(url, filePath) {
    return new Promise((resolve, reject) =&gt; {
      got.stream(url).on
          (&quot;response&quot;, response =&gt; {
              const newFile = fs.createWriteStream(filePath);
              response.pipe(newFile);
              newFile.on(&quot;finish&quot;, () =&gt; {
                newFile.close(resolve());
              });
              newFile.on(&quot;error&quot;, err =&gt; {
                reject(err);
              });    
          }).on
          (&quot;error&quot;, err =&gt; {
               reject(err);
          });
    });
  }
  </code></pre>
  <p>The <code>finish</code> event never fired. The file (<code>filePath</code>) is created with 0 bytes.</p>
  <p>The block of code using <code>newFile</code> was something that worked when I was using the Node <code>http</code> module.</p>
  <p>What is the proper way to pipe <code>got.stream</code> to a file?</p>