Function writeDirContents