changed for ability to write whole message includeing header