Added a check_file function to verify a file is not being written to.