with open("caffeine.mol","r") as molfile: for i in range(3): molfile.readline() line = molfile.readline() na = int(line[0:3]) nb = int(line[3:6]) #print(na) #print(nb) for i in range(na): line = molfile.readline() print(line[:-1])