[PHP] Text file hit counter Problems

Hrm, I have this snippet, that i got from a tutorial, to keep track of people visiting my site:


<?php
   $fp = fopen ( "counter.txt" , "r" );
   $count = fread ( $fp , filesize( "counter.txt" ));
   fclose ( $fp );
   $count ++;
   $fp = fopen ( "counter.txt" , "w" );
   fwrite ( $fp , $count );
   fclose ( $fp );
?>

When I include it and actually go to my site it gives me the following errors:

Warning: fopen(“counter.txt”, “w”) - Permission denied in /home/portfolio/www/functions.php on line 48

Warning: Supplied argument is not a valid File-Handle resource in /home/portfolio/www/functions.php on line 49

Warning: Supplied argument is not a valid File-Handle resource in /home/portfolio/www/functions.php on line 50

(http://portfolio.arctichosts.com/ if you want to see for yourself)

Any idea on how I can fix this?