Keep the status of the result of the loop in a variable (Create the variable before the loop) and rollback outside the loop based on the loop result. Don't commit inside the loop. Only change. If all ok, run a new loop and commit all.
Or use something with batch from community commons.