The counter is always just zero (0)

Code

$action=$_POST['action'];
$visitfile="visit.txt";
if($action==0){
$fp=fopen("$visitfile","r");
$num = fread($fp, filesize("$visitfile"));
fclose($fp);
$num++;
$fp=fopen("$visitfile","w");
fputs($fp , $num );
fclose($fp);
}
if($action==1){
$fp=fopen("$visitfile","r");
$num = fread($fp, filesize("$visitfile"));
fclose($fp);
echo "&outcount= Powered On: $num";
}
echo "&DUMP=";


$action is from flash
It is working on Apache
what should i do?