Comment

lars

In new1 you read the file f to the end.
and when you come to new2
f is at end of file.
Thats why
Before new2()
f.close()
f=open("hello.txt", "r")

Parent comment

raj

i seem to have a problem with readlines()as below, am i doing anything wrong? i have global f f=open("hello.txt", "r") f1 = open("C:\\log1.txt",'w') f2 = open("C:\\log2.txt",'w') def new1(): for line in f.readlines(): if line.find('raj')>= 0: f1.write("%s" %line) def new2(): for line in f.readlines(): if line.find('abc')>= 0: f2.write("%s" %line) new1() new2() i don't seem to get an output for new2 ,i mean it doesn't go through the for loop Am i doing anything wrong ??