NodeJS piping from readable to file writeStream not working
<p>I want to pipe content to file. Here's what I've wrote:</p>

<pre><code>var fs = require('fs');
var Readable = require('stream').Readable;

var ws = fs.createWriteStream('xfiles.txt');
var rs = new Readable;

ws.on('finish', function() {
    console.log('Written ' + ws.bytesWritten + ' ' + ws.path);
});

rs.push('foo bar baz');
rs.push('foo bar baz');
rs.push('foo bar baz');
rs.push(null);

rs.pipe(ws);
ws.end();
</code></pre>

<p>I expected the xfiles.txt to have 3 lines of 'foo bar baz'. But the output tells me that 0 bytes written, and when I check xfiles.txt it's empty.</p>

<p>What do I miss?</p>

<p><strong>EDIT</strong></p>

<p>Sorry, found the answer right after posting this question. The answer in <a href="https://stackoverflow.com/questions/13338350/nodejs-writestream-empty-file">this SO question</a> solved my problem.</p>