<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_into_collection_from_file(collection, filename, content_type=None):
 """ Loads resources from the specified file into the given collection resource. If no content type is provided, an attempt is made to look up the extension of the given filename in the MIME content type registry. """

    if content_type is None:
        ext = os.path.splitext(filename)[1]
        try:
            content_type = MimeTypeRegistry.get_type_for_extension(ext)
        except KeyError:
            raise ValueError('Could not infer MIME type for file extension '
                             '"%s".' % ext)
    load_into_collection_from_stream(collection, open(filename, 'rU'),
                                     content_type)