#4 using 'close' event instead of 'end' for pipe