Write structs to file