add write-file function