added check for empty dir & file