>> if line.startswith('notes'): >> break >> notes = open('myfile','r').read().split(notes:\n')[1] > > The first two lines are redundant you only need the last one. I should have clarified, the "if line.startswith" part was used to break out of the previous for loop, which was used to import the other, shorter strings.