Moved print statements inside try.