Append text to a Text file without replacing it Python : <p>Im new to python and I need some help from you guys. </p>

<p><strong>So this is my Code</strong></p>

<pre><code>Tk().withdraw() 
filename = askopenfilename(title='Choose a file', filetypes=[("Text Files", "*.txt")]) 

f = open(filename)


with open(filename,'r+',encoding="UTF-8") as file:
 file.write('test')
 file.write('\n')

file_contents = f.read() 
</code></pre>

<p><strong>This is the Text File without using file.write</strong></p>

<pre><code>Im a big noob in python please help me.
</code></pre>

<p><strong>And this is after using file.write</strong></p>

<pre><code>test
ig noob in python please help me.
</code></pre>

<p>My Goal is to append the Text to the top of the text file without replacing the contect underneath it.</p>
