Looping issues

brochu121 at gmail.com brochu121 at gmail.com
Thu Apr 5 20:01:09 CEST 2007

What I am trying to do is compare two files to each other.

If the 2nd file contains the same line the first file contains, I want
to print it. I wrote up the following code:

correct_settings = open("C:\Python25\Scripts\Output
current_settings = open("C:\Python25\Scripts\Output\output.txt","r")

for line in correct_settings:
        for val in current_settings:
            if val == line:
                print line + " found."


For some reason this only looks at the first line of the
correct_settings.txt file. Any ideas as to how i can loop through each
line of the correct_settings file instead of just looking at the first?

More information about the Python-list mailing list