What is the best way to count the number of lines in a huge file? Say, I have a file which is 15MB in size. I used: file=open("data.txt","r") n=0 for line in file.xreadlines(): n+=0 print n Is there a better/simpler way to do it? Thanks a lot. Hy