fix {mkdir}write twice problem by puting {mkdir} in main