In python why it won't print without newline
<p>I am new to learning python. I don't understand why print command will output all variables on screen but write command to file only writes 2 first two variables.</p>

<pre><code>print "Opening the file..."
target = open(filename, 'a+')

line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")
line4 = line1 + "\n" + line2 + "\n" + line3

# This command prints all 3 (line1,line2,line3) variables on terminal
print line4

#This command only writes line1 and line2 variables in file
target.write(line4)

print "close the file"
target.close()
</code></pre>