Interesting question. I'm not sure of the answer, but a kludgey workaround is to always make sure you start with something that will cause the flip-flop to reset:
They should work identically, as far as I can tell, but I can verify that the operator flops before leaving the subroutine now. This should work for both cases of input as I stated above.
That will only work if you are certain nothing in your for loop will bail out early, including something throwing an exception that's caught by a caller of your sub. Putting the dummy "\n" at the beginning of the loop is safer.