new directory write function