I don't know what is wrong with your code yet, but first you should clean it up. Either replace those backslashes with forward slashes, or put r before the first quote in the path string. This prevents special characters from being evaluated as such.
<br><br>Second, you should debug a little. Feel free to put print statements in!<br><br>correct_settings = open(r"C:\Python25\Scripts\Output\correct_settings.txt","r")<br>current_settings = open(r"C:\Python25\Scripts\Output\output.txt","r")
<br><br>for line in correct_settings:<br>        print "line=", line<br>        for val in current_settings:<br>            print "val=", val<br>            if val == line:<br>                print line, "found." ## please don't concatenate strings in the print statement! separate them with commas!
<br>                break ## You have already found that the same line is in both files: you don't need to keep searching<br><br><br>correct_settings.close()<br>current_settings.close()<br><br><br><div><span class="gmail_quote">
On 5 Apr 2007 11:01:09 -0700, <b class="gmail_sendername"><a href="mailto:brochu121@gmail.com">brochu121@gmail.com</a></b> <<a href="mailto:brochu121@gmail.com">brochu121@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
What I am trying to do is compare two files to each other.<br><br>If the 2nd file contains the same line the first file contains, I want<br>to print it. I wrote up the following code:<br><br><br><br>correct_settings = open("C:\Python25\Scripts\Output
<br>\correct_settings.txt","r")<br>current_settings = open("C:\Python25\Scripts\Output\output.txt","r")<br><br>for line in correct_settings:<br>        for val in current_settings:<br>            if val == line:
<br>                print line + " found."<br><br><br>correct_settings.close()<br>current_settings.close()<br><br><br>For some reason this only looks at the first line of the<br>correct_settings.txt file. Any ideas as to how i can loop through each
<br>line of the correct_settings file instead of just looking at the first?<br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote>
</div><br>