working on writing data to file