Implement header writing.