handle multiline chunks, cleanup writeStream