added directory handling: check and create
fixed util.fileWrite and added test