<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def serialize_yaml_tofile(filename, resource):
 """ Serializes a K8S resource to YAML-formatted file. """

    stream = file(filename, "w")
    yaml.dump(resource, stream, default_flow_style=False)