Invoking {{Wiki Markup remove()}} on an open file is [implementation-defined|BB. Definitions#implementation-defined behavior]. Removing an open file is sometimes recommended to hide the names of temporary files that may be prone to attack (see \[[FIO43-C. Temporary files must be dealt with in a secure manner]\]).
In cases requiring the removal of an open file, a more strongly defined function, such as the POSIX unlink() function, should be considered. To be strictly conforming and portable, remove() should not be called on an open file.
...