here is what you can do to prevent the file from being opened for writing by more than one script.
$fp = fopen("file.txt", "w");
flock($fp, LOCK_EX); //exclusive lock
//....writing etc
flock($fp, LOCK_UN); //unlock file
fclose($fp);
or for reading:
$fp = fopen("file.txt", "r");
flock($fp, LOCK_SH); //shared read lock
//...reading
flock($fp, LOCK_UN); //unlock
fclose($fp);
www.php.net/flock for more details.