[RGSS2/VX] How to check if an information exist in a file

Hello there.
I have a problem with a file that I created to save some information I have to save even between classical save.
How can I check if an information is in the file or not ?

That's the part of my script that load informations.
Code:
if File.exists?("Saveinfos.rvinfo")
      file2 = File.open("Saveinfos.rvinfo","rb")
      $mesinfos = Marshal.load(file2)
      $messucces = Marshal.load(file2)
      $succes_test = Marshal.load(file2)
      file2.close
end

As I'm still creating the game, it's sure that I will add some other variables in the file. But when I add that, I cant load any game save cause that cant find new variables.
I need to check if a variable exist in file and if not I could recreate this one as if I was starting a new game.

I dont know if it's clear enough, sorry if isnt. Was hard to try to explain that in english.
You need to show us how you're saving it too because how to load/check it is dependent on how you saved it.
Sorry^^
That's the part that save. I added it to the original save script.

Code:
  def save_save2
    file2 = File.open("Saveinfos.rvinfo","wb")
    Marshal.dump($mesinfos,file2)
    Marshal.dump($messucces,file2)
    Marshal.dump($succes_test,file2)
    file2.close
  end
Wait so the problem is that you cant load a save game made before you added the system since it tries to load the non existent variables?

And thru the course of develepment, you'd add more?

TBH, I'll just do this via the way the game normally do the save files, via the contents hash..

Code:
saveinfo = {}
saveinfo[:mesinfos] = $mesinfos
saveinfo[:messuccess] = $messuccess
#Add your other variables the same way
file2 = File.open("Saveinfos.rvinfo","wb")
Marshal.dump(saveinfo,file2)

Then on your load

Code:
file2 = File.open("Saveinfos.rvinfo","rb")
saveinfo = Marshal.load(file2)
$mesinfos = saveinfo[:mesinfos] unless saveinfo[:mesinfos].nil?
Really thanks you for that.
Nice idea to save all in that way. I dont know how many variable I will have to save, so it's really cool^^

Original thread: https://forums.rpgmakerweb.com/threads/rgss2-vx-how-to-check-if-an-information-exist-in-a-file.108955/