added write file and changed default layout structure