import csv


def write_csv(filename, headers, dataset):
    """
    Writes data to a CSV file.
    """
    with open(filename, 'w') as fp:
        wr = csv.DictWriter(
            fp,
            fieldnames=headers,
            quoting=csv.QUOTE_ALL,
            lineterminator='\r\n',
            delimiter=','
        )
        wr.writeheader()
        wr.writerows(dataset)

    return True