write outout to file
update
added comments