title: How to close a readable stream (before end)?
body: <p>How to close a <a href="http://nodejs.org/api/stream.html#stream_class_stream_readable">readable stream</a> in Node.js?</p>
  
  <pre><code>var input = fs.createReadStream('lines.txt');
  
  input.on('data', function(data) {
     // after closing the stream, this will not
     // be called again
  
     if (gotFirstLine) {
        // close this stream and continue the
        // instructions from this if
        console.log("Closed.");
     }
  });
  </code></pre>
  
  <p>This would be better than:</p>
  
  <pre><code>input.on('data', function(data) {
     if (isEnded) { return; }
  
     if (gotFirstLine) {
        isEnded = true;
        console.log("Closed.");
     }
  });
  </code></pre>
  
  <p>But this would not stop the reading process...</p>