Added checks for directory or file, directory iteration.