Corrected syntax error in for loop