Cannot read file after writing to it
<p>I am currently reading "Learn Python the hard way" and have reached chapter 16.<br> I can't seem to print the contents of the file after writing to it. It simply prints nothing.</p>

<pre><code>from sys import argv

script, filename = argv print "We are going to erase the contents of %s" % filename print "If you don\'t want that to happen press Ctrl-C" 
print "If you want to continue press enter"

raw_input("?") print "Opening the file..." target = open(filename, "w")

print "Truncating the file..." target.truncate()

print "Now i am going to ask you for 3 lines"

line_1 = raw_input("Line 1: ") 
line_2 = raw_input("Line 2: ") 
line_3 = raw_input("Line 3: ") 

final_write = line_1 + "\n" + line_2 + "\n" + line_3

print "Now I am going to write the lines to %s" % filename

target.write(final_write)

target.close

print "This is what %s look like now" %filename

txt = open(filename)

x = txt.read() # problem happens here 
print x

print "Now closing file"

txt.close
</code></pre>
