Fixed bug in downloading a file if directories are missing