def METHOD_NAME(loc, term_id, new_label):
    rows = []
    with open(loc, "r") as f:
        reader = csv.DictReader(f, delimiter="\t")
        headers = reader.fieldnames
        # Some templates have label capitalized
        if "Label" in headers:
            label_col = "Label"
        else:
            label_col = "label"
        for row in reader:
            if row["ontology ID"] == term_id:
                old_label = row.get(label_col)
                row[label_col] = new_label
            rows.append(row)
    with open(loc, "w") as f:
        writer = csv.DictWriter(f, delimiter="\t", fieldnames=headers, lineterminator="\n")
        writer.writeheader()
        for row in rows:
            writer.writerow(row)
    return old_label