I need to copy a file specified by the user and make a copy of it (giving it a name specified by the user). This is my code:
import copy
def main():
userfile = raw_input('Please enter the name of the input file.')
userfile2 = raw_input('Please enter the name of the output file.')
infile = open(userfile,'r')
file_contents = infile.read()
infile.close()
print(file_contents)
userfile2 = copy.copy(file_contents)
outfile = open(userfile2,'w+')
file_contents2 = outfile.read()
print(file_contents2)
main()
Something strange is happening here, as it doesn't print the contents of the second file, outfile.