fix writing of header (byte count) for StreamParser