NodeJS WriteFile CreateWriteStream
<p>Alright. Have these 2 pieces of code:</p>

<pre><code>// first example
request(imageUrl).then((data) =&gt; {
  var wstream = fs.createWriteStream('doodle');
  wstream.write(data);
})
// second example
request(imageUrl).pipe(fs.createWriteStream('doodle2'));
</code></pre>

<p>What I try to do is to save an image to disk. Second example works fine. But my question is: both examples do same task, but why do they produce different results?
Btw thats request-promise module in examples.</p>