def METHOD_NAME(input_file, output_file, output_json=True):
    fout = open(output_file, "w")
    with open(input_file) as fin:
        for line in tqdm(fin):
            row = json.loads(line.strip())
            wrong = "\n".join(clean(line) for line in row["diff"].split("\n") if not line.startswith("+"))
            correct = "\n".join(clean(line) for line in row["diff"].split("\n") if not line.startswith("-"))
            instruction = INSTRUCTON_TEMPLATE.format(wrong, correct)
            commit_msg = clean_commit_msg(row["commit_message"]) if "commit_message" in row else None
            if commit_msg:
                # template: (instruct, wrong_code, resposne_prefix, commit_message, correct_code)
                out_str = TEMPLATE_COMMIT_MSG.format(
                    gen_instruction(), wrong, gen_response_prefix(), commit_msg, correct
                )
                response = RESPONSE_TEMPLATE_COMMIT_MSG.format(gen_response_prefix(), commit_msg, correct)
            else:
                # no commit message
                out_str = TEMPLATE.format(gen_instruction(), wrong, correct)
                response = RESPONSE_TEMPLATE.format(correct)
            if output_json:
                row = {
                    "INSTRUCTION": instruction,
                    "RESPONSE": response,
                    "SOURCE": "TSSM-3M",
                    "METADATA": {
                        "project_url": row["project_url"],
                        "file_path": row["file_path"],
                        "commit_sha": row["commit_sha"],
                    },
                }
                out_str = json.dumps(row, ensure_ascii=False)
            print(out_str, file=fout)
        fout.close()