<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_file(file, array):
 """Wrapper around ndarray.tofile to support any file-like object"""


    try:
        array.tofile(file)
    except (TypeError, IOError, UnsupportedOperation):
        # tostring actually returns bytes
        file.write(array.tostring())