Please have a look at:
http://www.php.net/manual/en/function.fopen.php
You need to use exclusive locking while creating the the file like this:
$handle = fopen("/home/somewhere/yourfile.txt", "x");
When you do it like this the secondary access attempts (user B, C) to the file will return false and generate a warning since the file is created and exclusively locked by user A.
As soon as file is created file_exists will be true but the other users can not fopen it because it will be created with an exclusively locked state.
When user A finishes his/her job, the later invocations can access the file
Manual entry for modes x and x+ are as follows:
'x'
Create and open for writing only; place the file pointer at the beginning of the file. If the file already exists, the fopen() call will fail by returning FALSE and generating an error of level E_WARNING. If the file does not exist, attempt to create it. This is equivalent to specifying O_EXCL|O_CREAT flags for the underlying open(2) system call.
'x+'
Create and open for reading and writing; otherwise it has the same behavior as 'x'.