Fix when opening remote or invalid directory

It was giving an error when it's cding into the parent directory, if the
file is a remote file, or it's in an invalid path.