counter.txt with CHMOD 777 means it should be read and writable by the PHP script.

In windows you need to set the needed permission using IIS and for Linux its simply changing the file permission.

I have not tested but it should work with chmod 666 as well as you do not need to execute anything.