from sys import argv

script, filename = argv

print "We're going to erase the contents of %r." % filename
print "If you don't want that, hit CTRL-C ."
print "If you do want that, hit RETURN."

raw_input("Delete contents?")

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

print ""
print "Truncating the file. Bye bye data!"
print ""

print "Now I'm going to ask you for 3 lines."
line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")

print "Writing your lines to the file..."

target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")

print "Closing the file..."
target.close()

print "Re-opening and printing..."
target = open(filename, 'r+')
print target.read()

print "Re-closing..."
target.close()
