Define loop iteration variables as local in functions.