Fix small logic error where directories weren't being checked properly.