While checking the state of a file before using it, do not use the file name; it makes the file vulnerable. So use file descriptors instead of file names whenever possible.