okay, heres your problem... Windows does not support chmod, that is a linux thing. In windows all files are readable or writtable, unless specified otherwise.
to open a file, here is the code you need:
$counter_file = fopen("counter.txt", "w+");
$current_counts = fread($counter_file, filesize("counter.txt"));
$current_counts = $current_counts + 1;
fwrite($counter_file, $current_counts);
fclose($counter_file);
I believe that is correct...