add generate file write/read codes