Moved try finally outside of while loop