Python appending to file
<pre><code>while True:
    item = str(raw_input('Please enter the name of your item: '))
    f = open('sample.txt', 'a')
    f.write(item + '\n')
    f.close()
</code></pre>

<p>My goal is to get this to keep adding items to a text document, sample.txt. However, each time I run the program, the old data that was appended is written over... How to fix? To clarify, I want a running list in a text document of each item that is entered.   Thanks!</p>
