Placed main loop inside try/except/finally block