title: Detecting the end of a writeStream in Node
body: <p>This is what I've got, and I keep getting an error because the file doesn't exist yet when I just do it sequentially.</p>
  
  <p>How can I trigger an action upon the writeStream getting closed?</p>
  
  <pre><code>var fs = require('fs'), http = require('http');
  http.createServer(function(req){
      req.pipe(fs.createWriteStream('file'));
  
  
      /* i need to read the file back, like this or something: 
          var fcontents = fs.readFileSync(file);
          doSomethinWith(fcontents);
      ... the problem is that the file hasn't been created yet.
      */
  
  }).listen(1337, '127.0.0.1');
  </code></pre>