Make looping work in the run command

There's a bit of a bug, where if you change a flag while using the loop,
the script won't recognize it until all loops are done.