adding file write out and step functionality