UNO won't write data to SD card inside one particular while loop

It was working earlier, now it suddenly isn’t. Very confused. Sometimes it won’t write inside other loops. I’m only using 72% of the SRAM. Am running off of my computer’s USB drive. Any ideas?

The loop in question here is the “while (ascent > 0 && kill2 < 3)” loop

I’m launching this thing tomorrow morning, so I’d really appreciate any help!

/* SD SD SD SD SD */
#include <SPI.h>
#include <SD.h>
File myFile;
/* END SD END SD END SD END SD */



/* SERVO SERVO SERVO SERVO */
#include <Servo.h>  // servo library
Servo servo1;  // servo control object
/* END SERVO SERVO SERVO SERVO */

/*ALTIMETER */
#include <Wire.h> 
#include "IntersemaBaro.h"
Intersema::BaroPressure_MS5607B baro(true);
/* END ALTIMETER */

void setup() { 
  
  delay(3000);

  
  /*SD SD SD SD SD SD SD SD SD SD SD SD SD */

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect.
  }
  Serial.println(F("Initializing SD card..."));
  pinMode(10, OUTPUT);

  if (!SD.begin(4)) {
    Serial.println(F("initialization failed!"));
    return;
  }
  Serial.println(F("initialization done."));
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.println(F("Writing to test.txt..."));
    myFile.println("BEGIN NEW FLIGHT");
    // close the file:
    myFile.close();
    Serial.println(F("done."));
  } else {
    // if the file didn't open, print an error:
    Serial.println(F("error opening test.txt"));
  }
  /* END SD END SD END SD END SD END SD */
  
    myFile = SD.open("test.txt", FILE_WRITE);

    myFile.println("NF");
    myFile.close();

  
   /* SERVO SERVO SERVO */
 
   // initialize digital pin 13 as an output.
      pinMode(3, OUTPUT);
      servo1.attach(9);
      servo1.write(170); 

   /* END SERVO SERVO SERVO */

    Serial.begin(9600);
    baro.init();
 
 
 
 // BEGIN FLIGHT BEGIN FLIGHT
 
    float alt1 = baro.getHeightCentiMeters();
    delay(1000);
    float alt2 = baro.getHeightCentiMeters();
    delay(1000);
    float alt = (alt2)-(alt1);
    float kill1 = 0;
  
 
    while (alt < 609600 && kill1 < 5) {
       float alt3 = baro.getHeightCentiMeters();
       delay(1000);
       alt = alt3-alt1;
  
       myFile = SD.open("test.txt", FILE_WRITE);
       myFile.print((float)millis()/1000);
       myFile.print(",");
       myFile.println((float)(alt) / 30.48);
       myFile.close();
       delay(1000);
       
       kill1++;
 
   }
  
// OPEN VENT!!  
  
    myFile = SD.open("test.txt", FILE_WRITE); 
    myFile.println("BV");
    myFile.close();
    servo1.write(0); 
  
  /* Wait for ascent rate to become less than 100 cm/s */

  float ascent = 1;
  float kill2 = 0;
  
  while (ascent > 0 && kill2 < 3) {
   
    myFile = SD.open("test.txt", FILE_WRITE); 
    myFile.println("OV");
    servo1.write(0);   

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000);

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000);

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000); 

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000); 

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000); 
    // CLOSE VENT TO CHECK ASCENT RATE
 
    myFile.println("CV");
    servo1.write(170);
    
    float asc1 = baro.getHeightCentiMeters();
    delay(2000);

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000);

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000);

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000); 

    myFile.print((float)millis()/1000);
    myFile.print(",");
    myFile.println((float)baro.getHeightCentiMeters()-(alt1));
    delay(2000); 
    float asc2 = baro.getHeightCentiMeters();
    ascent = ((asc2)-(asc1))/10;
 
    
    myFile.print("AR:");
    myFile.println((float)(asc2)-(asc1));
    kill2++;   
  }

  
    myFile = SD.open("test.txt", FILE_WRITE);
    myFile.println("CV1");
    
    servo1.write(170);
    delay(1000);
    servo1.write(50);
    delay(1000);
    servo1.write(170);
    delay(1000);
    servo1.write(50);
    delay(1000);
    servo1.write(170);
    delay(1000);
    servo1.write(50);
    delay(1000);

    
    // TIMER UNTIL SOFT LANDING
    
    int i=0;
    myFile.println(i);
    
    while (1) {
      myFile = SD.open("test.txt", FILE_WRITE); 
      float time = millis();
      if (i > 10) {   
        myFile.println("TF");
        servo1.write(0);
        
        while(1){
      
          myFile.print((float)millis()/1000);
          myFile.print(",");
          myFile.println((float)baro.getHeightCentiMeters()-(alt1));
        }
      }
      else {
        myFile.println("time low");
    
        myFile.print((float)millis()/1000);
        myFile.print(",");
        myFile.println((float)baro.getHeightCentiMeters()-(alt1));
        
        servo1.write(170); 
      }
      myFile.close();
      
      i++;
      
      delay(2000);
      }
 
}

void loop() {}

Inside that loop you seem to open the file but not close it.