This has to be inside of the conditional in order for the actual data to be written to the stream.

I tested this on a high level in gulp, see this gist: https://gist.github.com/lazd/7964385 . With `r.end()` outside of the conditional, the stream ends without the file being emitted. With it inside of the conditional, it works as expected.