title: node stream error
body: <p>Hi i'm currently playing with node and got an error i dont know how to fix :</p>
  
  <pre><code>stream.js:81
  throw er; // Unhandled stream error in pipe.
  
  Error: socket hang up
      at createHangUpError (http.js:1344:15)
      at Socket.socketOnEnd [as onend] (http.js:1432:23)
      at TCP.onread (net.js:419:26)
  </code></pre>
  
  <p>My script read a file which contains urls of a pages who themselves contains url of an image
  i download and save. Can you explain how to fix this ? Sorry for my english...</p>
  
  <pre><code>var fs = require('fs');
  var request = require('request');
  var lazy = require('lazy');
  
  var lines = new lazy(fs.createReadStream('./' + dir + '/links.txt'))
      .lines
      .forEach(function (line) {
  
          var req = request(line, function (error, res, body) {
  
              if(res.statusCode == 200) {
                  var urlImg = body.match(/&lt;img id="img".+?src="(.+?)"/)[1];
                  var stream = fs.createWriteStream(urlImg);
                  var req2 = request(urlImg).pipe(stream);
              };
          });
  
      });
  </code></pre>