Desperate.. Toggle Loop

I've posted this in another section and had some help but still have not figured it out.

I'll keep it short and simple:
I need the loop to start and stop with the push of a button.
Push button, start and repeat loop for x amount, push button, stop loop. Rinse, repeat, if necessary.

#include <SPI.h>
#include <SD.h>
#include <RTClib.h>
#include <max6675.h>

//SD card
const int chipSelect = 10; 

//Thermocouple
int ktcSO = 7;
int ktcCS = 6;
int ktcCLK = 5;

//Push button
int buttonPin = 9;
int buttonState;
int prevButtonState = 0;

//Thermocouple
MAX6675 ktc(ktcCLK, ktcCS, ktcSO);

File myFile;

RTC_DS1307 rtc;

void setup() 
{
  pinMode(buttonPin, INPUT_PULLUP);
  
  Serial.begin(9600);
  
  // setup for the RTC
  while(!Serial);
    if(! rtc.begin()) {
      Serial.println("Couldn't find RTC");
      while (1);
    }
    else {
      // following line sets the RTC to the date & time this sketch was compiled
      rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    }
    if(! rtc.isrunning()) {
      Serial.println("RTC is NOT running!");
    }
    
  // setup for the SD card
  Serial.print("Initializing SD card...");

  if(!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
    
  //open file
  myFile=SD.open("Test.txt", FILE_WRITE);

  // if the file opened ok, write to it:
  if (myFile) {
    Serial.println("File opened ok");
    // print the headings for our data
    myFile.println("Date, Time, Temperature ºC");
  }
  myFile.close();
}


void loggingTime() 
{
     DateTime now = rtc.now();
   char dateBuffer[12];

   sprintf(dateBuffer,"%02u-%02u-%04u ",now.month(),now.day(),now.year());
   Serial.print(dateBuffer);

   sprintf(dateBuffer,"%02u:%02u:%02u ",now.hour(),now.minute(),now.second());
   Serial.println(dateBuffer);


  myFile = SD.open("Test.txt", FILE_WRITE);
  if (myFile) {
    myFile.print(now.month(), DEC);
    myFile.print('/');
    myFile.print(now.day(), DEC);
    myFile.print('/');
    myFile.print(now.year(), DEC);
    myFile.print(", ");
    myFile.print(dateBuffer);
    myFile.print(", ");
  }
  Serial.print(dateBuffer);
  Serial.print(", ");
  myFile.close();
  delay(1000);  
}

void loggingTemperature() 
{
  myFile = SD.open("Test.txt", FILE_WRITE);
  if (myFile) {
    Serial.println("open with success");
    Serial.print(ktc.readCelsius());
    Serial.println(",");
    myFile.print(ktc.readCelsius());
    myFile.println(" ");
  }
  myFile.close();
}


void loop() {
buttonState=digitalRead(buttonPin);
if(buttonState==0 && prevButtonState==1){
    loggingTime();
    loggingTemperature();
}
else{
  }
  buttonState=prevButtonState;
  delay(100);
}

I have no idea how to word(code) this, I want it to do something (logging time and temp) when I press it once, and NOTHING when I press it again. I have watched several videos, search forums and google, and no luck... is there a simple way to start and stop a loop I am unaware of? I have tried boolean..but still not sure how to word it. If you cant tell I am fairly new to this, but have learned enough to get me by so far. This works perfectly if I just plug and unplug it, but I want a button to do that. Even if the button simply powers on and off the device so I can take out of the serial wait.

Pseudo code:

loop() {

service buttons
if button activated, toggle true/false state of run flag

if (run flag is true) {
do all the stuff you want to either perform or not perform
}

}

Some toggle code (not mine) that has some button debounce functions included. You might test just having it print something to the serial monitor.

boolean toggleState; // hold current state of switch
boolean lastToggleState;  // hold last state to sense when switch is changed
long toggleTimer = millis();  // // debounce timer

void setup(){
// setup stuff here
}

void loop(){

toggleState = digitalRead(toggleSwitchPin); 

if (millis() - toggleTimer > 100){  // debounce switch 100ms timer
   if (toggleState && !lastToggleState) {  // if switch is on but was previously off
     lastToggleState = true;  // switch is now on
     toggleTimer = millis();  // reset timer
     // do stuff here
   }

   if (!toggleState && lastToggleState){  // if switch is off but was previously on
     lastToggleState = false; // switch is now off
     toggleTimer = millis(); // reset timer
     // do stuff here
    }
  }
}

Another way to consider the bare task (because it could get much more complicated than this example) is that you can create your own loop such as:

void myLoop() { etc. }

which you then call or not call in the actual loop() function, depending on what your switch logic has decided. One way or another, the switch logic must always run, because the response would be too slow otherwise.