This works perfectly with the dummy data provided in the original post, but the regex to skip the END line might be a bit dangerous because real data might contain a 'E'. In addition, if the file is large, it might be better to do a last, rather than a next, when the line with the END tag is met.