<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _write_header(name, header, required, stream, encoder, strict=False):
 """ Write AMF message header. @param name: Name of the header. @param header: Header value. @param required: Whether understanding this header is required (?). @param stream: L{BufferedByteStream<pyamf.util.BufferedByteStream>} that will receive the encoded header. @param encoder: An encoder capable of encoding C{AMF0}. @param strict: Use strict encoding policy. Default is C{False}. Will write the correct header length after writing the header. """

    stream.write_ushort(len(name))
    stream.write_utf8_string(name)

    stream.write_uchar(required)
    write_pos = stream.tell()

    stream.write_ulong(0)
    old_pos = stream.tell()
    encoder.writeElement(header)
    new_pos = stream.tell()

    if strict:
        stream.seek(write_pos)
        stream.write_ulong(new_pos - old_pos)
        stream.seek(new_pos)