The "cacheout" function will make sure that there's a file handle open
for reading or writing available as the path name you give it. It
automatically closes and re-opens files if you exceed your system
maximum number of file descriptors, or the suggested maximum.