def save_output(output, list_to_save): if not output: with open(output, "w") as f: for item in list_to_save: f.write("%s\n" % item) print(f"Output file: {output}")