Move loop variable update.
Thanks to Dmitri Gribenko for the suggestion.