<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_catalog(detections, fname, format="QUAKEML"):
 """Write events contained within detections to a catalog file. :type detections: list :param detections: list of eqcorrscan.core.match_filter.Detection :type fname: str :param fname: Name of the file to write to :type format: str :param format: File format to use, see obspy.core.event.Catalog.write \ for supported formats. """

    catalog = get_catalog(detections)
    catalog.write(filename=fname, format=format)