is there any fs caching used here in the file exists check? or else this code will be very slow on filesystems like nfs, and then we should get a dirlisting and search in there instead