...
Unfortunately, this solution is subject to a TOCTOU (time-of-check-, time-of-use) race condition. It is possible for an attacker to modify the file system after the empty file is created but before the file open call such that the file that is opened is not the file that was created.
...