Awesome @mratsim, that's a great explanation and I understand better what was going on.
In the original version of the code, then, I guess I could define a function that parses individual lines just fine, and wrap the calls in an external loop, rather than doing everything inside.