with open ('av.txt', 'r') as d: rg = 1 count = 0 while rg < 601: for line in d: x = int(line.split('\t')[1].rstrip()) if x > rg: count = count + 1 print(str(rg) + ': ' + str(count)) rg = rg + 1 # count = 0