fix open_file() logic