Avoid null pointer when the directory is empty