file_exists logic fixed