Deleting a line stored in a variable in Python
<p>The global variable <code>originalInfo</code> contains </p>

<pre><code>Joe;Bloggs;j.bloggs@anemail.com;0715491874;1
</code></pre>

<p>I have written a function to delete that line in a text file containing more information of this type. It works, but it is really clunky and inelegant.</p>

<pre><code>    f = open("input.txt",'r') # Input file
    t = open("output.txt", 'w') #Temp output file

    for line in f:
        if line != originalInfo: 
            t.write(line) 

    f.close()
    t.close()
    os.remove("input.txt")
    os.rename('output.txt', 'input.txt')
</code></pre>

<p>Is there a more efficient way of doing this? Thanks</p>