title: Hits counter in txt file count visitors when open page simultaneously
body: <p>I am using this to count the hits to my website:</p>
  
  <pre><code>$counter_name = "counter.txt";
  
  $f = fopen($counter_name,"r");
  $counterVal = fread($f, filesize($counter_name));
  fclose($f);
  
  $counterVal++;
  $f = fopen($counter_name, "w");
  fwrite($f, $counterVal);
  fclose($f); 
  </code></pre>
  
  <p>I want to ask you if there could be a problem when 2 or more visitors opens the page at the same time? If yes, how to make this to count all hits?</p>
  
  <p>When (for example) 100 users opens the page at exactly same time, the file won't be locked by one of them?</p>
  
  <p>Thanks a lot!</p>