Are the UNIX permissions set correctly on the file "counter.txt"?
Try setting the permissions on this file to "777" and running the script.
If you have shell access you can do that by typing "chmod counter.txt 777".
If you only have FTP access to the server there should be an option in your FTP client that allows you to set permissions on remote files. Usually if you right click on the file name it'll give you that option. Make sure that you have read,write and execute permission on 'counter.txt'.
If the file does not exist, simply upload an empty file named counter.txt to the server and make sure it has the necessary permissions.
That should solve your problem.
Chris