started adding functionality to write to file