<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_data(fo, datum, schema):
 """Write a datum of data to output stream. Paramaters fo: file-like Output file datum: object Data to write schema: dict Schemda to use """


    record_type = extract_record_type(schema)
    logical_type = extract_logical_type(schema)

    fn = WRITERS.get(record_type)
    if fn:
        if logical_type:
            prepare = LOGICAL_WRITERS.get(logical_type)
            if prepare:
                datum = prepare(datum, schema)
        return fn(fo, datum, schema)
    else:
        return write_data(fo, datum, SCHEMA_DEFS[record_type])