fixing a bug in calling file() vs. dir()