your code would work for one line, look at my code. I put the regex in a while loop and had /mg which means match globally, this makes it work for all lines in file. word1 is the word where you want to start recording the data and word2 is where you want to end the reading of the data. The (.+) is everything in between those two words (non inclusive), and $1 represents the data in (.+).