conter = counter +1; → little typo —> wrong
counter = counter +1; —> right
Correct this typo and normaly it should work.