Use arithmetic expansion rather than arithmetic tests to increment

$((expression)) returns the value of an expression:
((expression)) performs a test for 0 or truthiness. Putting an
increment/decrement expression in a test causes that test to exit
with a non-zero status - which, with set -e, ends the script's
execution.