It will certainly not work on all operating systems. In Unix environment you need superuser privileges to know if a file is opened by some other process.