Fixed a null-pointer exception if the directory does not exists/no file
exists in the directory