Your inner for loop is processing the same line twice (or more precisely: it processes the same line the same number of times as the total number of rules you have, in this case, two).
Sounds like what you need is a flag to indicate either that you are currently between a statment declaration and end or to keep track of which statement you are currently in.
Is it necessary for you to use the range operator to grab the statements (e.g. A, B, C?)