Fix syntax error in loop