Also add 'error' event handler for the writeStream and move it infront of the
pipe call.

Also make sure 'callback' is only called once.