Write a program in Python 3.5 that reads a file, then writes a different file with the same text that was in the first one as well as more?
<p>The exact question to this problem is:
*Create a file with a 20 lines of text and name it âlines.txtâ. Write a program to read this a file âlines.txtâ and write the text to a new file, ânumbered_lines.txtâ, that will also have line numbers at the beginning of each line.
Example: 
Input file: âlines.txtâ</p>

<pre><code>Line one
Line two
</code></pre>

<p>Expected output file:</p>

<pre><code>1 Line one
2 Line two
</code></pre>

<p>I am stuck, and this is what I have so far. I am a true beginner to Python and my instructor does not make things very clear. Critique and help much appreciated.</p>

<pre><code>file_object=open("lines.txt",'r')
for ln in file_object:
    print(ln)

count=1
file_input=open("numbered_lines.txt",'w')
for Line in file_object:
    print(count,' Line',(str))
    count=+1
file_object.close
file_input.close
</code></pre>

<p>All I get for output is the .txt file I created stating lines 1-20. I am very stuck and honestly have very little idea about what I am doing. Thank you</p>

<ol>
<li><p>In the first loop you're printing the contents of the input file.  This means that the file contents have already been consumed when you get to the second loop.  (Plus the assignment didn't ask you to print the file contents.)</p></li>
<li><p>In the second loop you're using <code>print()</code> instead of writing to a file.  Try <code>file_input.write(str(count) + " " + Line)</code>  (And <code>file_input</code> seems like a bad name for a file that you will be <em>writing</em> to.)</p></li>
<li><p><code>count=+1</code> sets count to <code>+1</code>, i.e. <em>positive one</em>.  I think you meant <code>count += 1</code> instead.</p></li>
<li><p>At the end of the program you're calling <code>.close</code> instead of <code>.close()</code>.  The parentheses are important!</p></li>
</ol>

python file