I was working on the code of exercise 17 of Learn python the Hard way and got this error? : copying from test.txt to new1_file.txt
 
The input file is 8 bytes long
 
Does the output file exists, True
 
readyy, hit RETURN to continue, CTRL-C to abort

Traceback (most recent call last):
  File "ex17a.py", line 18, in <module>
    out_file.write(indata)
TypeError: argument 1 must be string or read-only character buffer, not file

This is the code that i used :-

from sys import argv

from os. path import exists

script, from_file, to_file = argv

print "copying from %s to %s" % ( from_file, to_file)

indata = open(from_file,'r')

print " The input file is %d bytes long" % len(from_file)

print " Does the output file exists, %r" %exists(to_file)
print " readyy, hit RETURN to continue, CTRL-C to abort"

raw_input()

out_file = open(to_file, 'w')
out_file.write(indata)

print " Alright, all done"

out_file.close()
indata.close()