Added check_file() function