Added a check to make the tmp directory if it doesn't already exist