tmp=file.read() (very huge file) if targetStr in tmp: print "find it" else: print "not find" file.close() I checked if file.read() is huge to some extend, it doesn't work, but could any give me some certain information on this prolbem?