All,
I had the exact same problem with the cpanel counter script. What was odd about it was that the HTML code as supplied by the cpanel counter-maker worked when I viewed my page via IP/~username (which is how one sees their page before the DNS has propagated), but didn't work (i.e., gave the error message "Could not write to counter file...") when accessed via the URL, even after DNS propagation was complete.
I dropped the ".dat" from the code snippet, as many have suggested, and now the problem is exactly reversed: It works fine when addressed as http://PIC-an-LCD.com, but not when accessed via IP/~username. Of course, this is much preferrable, as the world at large is going to find my page via the published URL.
It's still a head-scratcher, though.
Thanks,
Dale