Implementation of serialization and saving in files