title: Error: EMFILE: too many open files
body: <p>Using nw.js, I am just trying to save images in an array of img elements with different random names.</p>
  
  <p>But having a few errors, is something wrong with my code?</p>
  
  <pre><code>for (i = 0; i &lt; imgs.length; i++) {
   request(imgs[i].getAttribute('src')).on('error', function(err) {
    throw err
   }).pipe(fs.createWriteStream('data/imgs/' + randomString))
  }
  </code></pre>
  
  <p>imgs[] is an array of 100-500 html  img element, but I am receiving </p>
  
  <pre><code>Error: EMFILE: too many open files, open *&lt;directory&gt;*
  </code></pre>
  
  <p>And another error:</p>
  
  <pre><code>"Uncaught Error: socket hang up"
  </code></pre>
  
  <p>Although it saves some images, some of them are corrupted, and it creates too many images than there actually is.</p>