write prefix and content to stream at same time to increase performance