Increased scope of for loop to include try statement. Otherwise the loop doesn't catch the error it's supposed to.