Corrected error where frame collection would continue indefinitely.

Rolled loop and check condition into combined expression for the while loop.