check if a line exists in a file python
<p>How can I check if a line exists in a file and write the line to the file if it does not exist using Python</p>

<p>this is my current attempt</p>

<pre>

    logfile = open('ip.log', 'a+')

    while 1:
        line = logfile.readline()
        #line.replace("\n", "")
        print line

        if line == str(self.CLIENT_HOST):
            print "Line Found Skipping"
        else:
            logfile.write(str(self.CLIENT_HOST)+"\n")
        if not line:
            print "EOF Reached"
            break
        print line
    logfile.close()

</pre>

<p>cheers</p>
