Fixed part of saving to file logic