you get the error probably, inside your folder dun have "sub" folder name. you need to check it, if didnt found the folder, u need create a new folder.
based on the code, i didnt found any coding that create a new folder when the system didnt found ur folder.
hope it can help u