Not concatenating in same line
<p>This is my code:</p>

<pre><code>with open('test1.txt') as f:
    print "printing f"
    print f
    print '**********************'
    for line in f:
        print "printing line each"
        print line
        print '********'
        line2=line.upper()+"abc"
        print "printing line 2"
        print line2
        print '********'
        open('testout.txt','a').write(line2)
</code></pre>

<p>And for this I am getting this output:</p>

<pre class="lang-none prettyprint-override"><code>printing line 2
ROMA
abc
</code></pre>

<p>instead of:</p>

<pre class="lang-none prettyprint-override"><code>printing line 2
ROMAabc
</code></pre>

<p>I can't understand what is wrong, can someone help me understand?</p>

<p>P.S: I tried using <code>join</code> method as well, and still got the same result.</p>

<p>I am using python 2.7</p>

<p>line contains '\n' at the end, you can use this for your goal:</p>

<pre><code>line.strip().upper()
</code></pre>

python python-2.7 concatenation