Reading and writing player data from an SD card

I'm prototyping this system for a larger progect, and I had a few questions.
What I want to happen is when i press the button on the board, a player's level progress goes up by one. when that level progress reaches 10, the player's level should go up, and this all gets displayed on the serial monitor. I want the level progress and level to be saved to different files on the SD card, so they can be read for future use.

#include <TinkerKit.h>

TKButton button(I0);	// creating the object 'button' that belongs to the 'TKButton' class 


TKLed led(O0);		// creating the object 'led' that belongs to the 'TKLed' class 


#include <SD.h>

File playerlevel;
File playerlevelprogress;

  
  int level = 1;

  
  int levelprogress = 0;
 
  


void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  pinMode(10, OUTPUT);
  Serial.println("initialization done.");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  

}

void loop()
{
 
  


  if (button.pressed() == HIGH){
    levelprogress += 1;
    Serial.println("Level progress = ");
    Serial.println(levelprogress);
    SD.open("playerlevelprogress", FILE_WRITE);
    playerlevelprogress.write(levelprogress);
    playerlevelprogress.close();
    SD.open("playerlevel", FILE_READ);
  
  }

  if (levelprogress == 10){
    level += 1;
    Serial.println("Level up! Level ");
    Serial.println(level);
    SD.open("playerlevel", FILE_WRITE);
    playerlevel.write(level);
    playerlevel.close();
    levelprogress = 0;
    SD.open("playerlevel", FILE_READ);
  
  }

  delay(100);
}

It works all according to plan, but if I click out of the serial monitor, and bring it back up, everything resets. I'm assuming this has something to do with the way i'm defining the integers , and I tried defining the integers as whatever was read from the specific file on the SD card, but when that happens the counter for the level progress stays at 0. That's kind of a mystery to me.

How could I program this so that I actually save the information on the SD card, so that when I restart the serial monitor, the counter starts at the same place it stopped before I closed it down?

What I want to happen is when i press the button on the board

What button on what board? Wouldn't a switch work better?

    SD.open("playerlevelprogress", FILE_WRITE);

The open() method returns an instance of a File. Why are you discarding that instance?

    playerlevel.write(level);
    playerlevel.close();

You've never assigned a value to playerlevel.

What button on what board? Wouldn't a switch work better?

A button is better for my needs right now. It just acts as a trigger event right now and will be replace with code later.

The open() method returns an instance of a File. Why are you discarding that instance?

What do you mean by that? What would I use the instance for?

You've never assigned a value to playerlevel.

I've edited it a little bit, taking some bits from the 'readwrite' example.

#include <TinkerKit.h>

TKButton button(I0);	// creating the object 'button' that belongs to the 'TKButton' class 


TKLed led(O0);		// creating the object 'led' that belongs to the 'TKLed' class 


#include <SD.h>

File myFile1;
File myFile2;
File readFile1;
File readFile2;
 


int levelprogress = readFile2;



void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  pinMode(10, OUTPUT);
  Serial.println("initialization done.");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  myFile1 = SD.open("playerlevel.txt", FILE_WRITE);
  myFile2 = SD.open("playerlevelprogress.txt.", FILE_WRITE);
  readFile1 = SD.open("playerlevel.txt", FILE_READ);
  readFile2 = SD.open("playerlevel.txt", FILE_READ);
  int levelprogress = readFile2;
}

void loop(){
 
  if (button.pressed() == HIGH){
    levelprogress += 1;
    Serial.println("Level progress = ");
    Serial.println(levelprogress);
    myFile2.println(levelprogress); 
    myFile2.close();

  }

  if (levelprogress == 10){
    int level = readFile1;
    level += 1;
    Serial.println("Level up! Level ");
    Serial.println(level);
    myFile1.println(level);
    myFile1.close();
    levelprogress = 0;

  }

  delay(100);
}

Is this closer than before or am I wasting my time right now?

A button is better for my needs right now.

If you have a shirt that needs closing. Otherwise, a switch is better!

What do you mean by that? What would I use the instance for?

Are you serious? The open() method returns the instance that you need to use for the read() calls.

Is this closer than before or am I wasting my time right now?

If you are using a 328-based Arduino, you've used up every bit of memory having 4 open files at once. There is no reason that I can see to have the same file opened three times - once for write and twice for read.