Fixed a bug where 'end' would be emitted before the last 'data' event.