added function to write party state to file