That *shouldn't* be the problem, since files are iterable<br><br><div><span class="gmail_quote">On 5 Apr 2007 11:18:50 -0700, <b class="gmail_sendername">anglozaxxon</b> <<a href="mailto:anglozaxxon@gmail.com">anglozaxxon@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;">On Apr 5, 2:01 pm, <a href="mailto:brochu...@gmail.com">brochu...@gmail.com
</a> wrote:<br>> 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>> 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>> correct_settings.close()
<br>> current_settings.close()<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>Instead of "for line in correct_settings", try "for line in<br>correct_settings.readlines()".<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>