Storing data read from Serial in a file in computer / device's flash memory

I use a NodeMCU ESP8266 to do a very simple and stupid project to make time pass faster. But I write a lot of code just for one purpose : using in the future.
I wrote this subroutine :

void setup() {
  pinMode(LED_PIN, OUTPUT); 
  Serial.begin(9600); 
  delay(3000);
  Serial.println(); 
  while(ssid == "") {
    Serial.println("Enter your SSID: "); 
    ssid = Serial.readString();
    } 
  while(wifi_password == "") {
    Serial.println("Enter your WiFi password: "); 
    wifi_password = Serial.readString();
    }
  ssid.replace("\n", ""); 
  wifi_password.replace("\n", ""); 
    
  Serial.print("SSID: "); 
  Serial.println(ssid); 
  Serial.println("Password you entered has " + String(wifi_password.length()) + " characters!"); 

  Serial.print("Now connecting to: "); 
  Serial.println(ssid); 

  WiFi.begin(ssid, wifi_password); 
  Serial.print("Connecting...");

  digitalWrite(LED_PIN, HIGH); 
  while(WiFi.status() != WL_CONNECTED) {
    delay(500);  
    Serial.print("."); 
    }
  Serial.println(" "); 
  Serial.println("Connected to your network!"); 
  digitalWrite(LED_PIN, LOW); 
  
  Serial.println("Use this URL to connect: "); 
  Serial.print("http://");
  Serial.println(WiFi.localIP()); 

}

And as you can see, this thingy actually asks for the SSID of my router and then asks the password. Why you ask? Because I think it's safer than hard-coding the damn thing right into the code. So, is there any way to store and retrieve the data? I saw PROGMEM guides but apparently it does not work on NodeMCU (no surprise, of course) and it would be good to find a way to store this credentials in the device, or in a file on the host computer.

Well, PROGMEM is hard coded. Perhaps you meant EEPROM? Some boards don’t have any, some of those offer EEPROM emulation in flash memory. It’s possible the ESP core offers an EEPROM emulation library.

aarg:
Well, PROGMEM is hard coded. Perhaps you meant EEPROM? Some boards don't have any, some of those offer EEPROM emulation in flash memory. It's possible the ESP core offers an EEPROM emulation library.

Thanks, I'll take a look.

Perhaps saving it to a .txt file on the NodeMCU using SPIFFS?