<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_csv(graph: BELGraph, file: Optional[TextIO] = None, sep: Optional[str] = None) -> None: """Write the graph as a tab-separated edge list. The resulting file will contain the following columns: 1. Source BEL term 2. Relation 3. Target BEL term 4. Edge data dictionary See the Data Models section of the documentation for which data are stored in the edge data dictionary, such as queryable information about transforms on the subject and object and their associated metadata. """

    if sep is None:
        sep = '\t'

    for u, v, data in graph.edges(data=True):
        print(
            graph.edge_to_bel(u, v, edge_data=data, sep=sep),
            json.dumps(data),
            sep=sep,
            file=file,
        )