from sys import argv import os if len(argv) < 3: print("Usage: python copy.py donor recipient") quit() donor = argv[1] recipient = argv[2] if not os.path.exists(donor): print("You are attempting to copy from a nonexistent file.") quit() with open(donor, "r") as fp_in: with open(recipient, "w") as fp_out: for line in fp_in: fp_out.write(line) ## copy file donor to recipient ## open the donor to read it. ## open the recipient for writing ## copy each line from the donor to the recipient ## ensure both files are closed at the end.