check that chdir worked before trying to read directory (genji@topaz)