Everything that Uncle Joe says above is spot on. This is just basic load / save and oceans of digital ink have been splashed all over the planet about how to do it. It’s a very well-travelled area of study and requires a lot of attention to detail. I have even held forth on it myself:
Load/Save steps:
Don’t use the binary formatter/serializer: it is insecure, it cannot be made secure, and it makes debugging very difficult, plus it actually will NOT prevent people from modifying your save data on their computers.