Python: How to append a file in python using inputs? : <p>I am fairly new to python, and have been trying to create a program where I create a file from user inputs. However, I cannot seem to get it to work, and keep getting the error:</p>

<pre><code>Traceback (most recent call last):
    File "my_program.py", line 7, in &lt;module&gt;
        my_file.append(x)
AttributeError: '_io.TextIOWrapper' object has no attribute 'append'
</code></pre>

<p>I think this means that I cannot append the file, but I am not sure at all why. Here is the relevant part of my program:</p>

<pre><code>my_file = "my_file"
with open(my_file, 'a') as my_file:
    lines = True
    counting_variable = 0
    while lines:
        x = input()
        my_file.append(x)
</code></pre>

<p>Thank you very much for any help in advance!</p>
