Yes,the code runs sequentially, and very fast. It can't detect your button input unless it has time/loop, or is waiting for it. Easiest way is to infinitely loop, then exit loop when button is pushed.