Help with GIFs

so im trying to have a gif play for 200 frames, then stop and relaunch the preAutonomous callback to re-initialize my GUI. Problem is i cannot get it to read code after the for loop

bool k = true;

while(k) {

if( (Brain.Screen.xPosition() >= 245 && Brain.Screen.xPosition() <= 360) && (Brain.Screen.yPosition() >= 0 && Brain.Screen.yPosition() <= 240) ) {
      Brain.Screen.clearScreen();

      int countgif = 0;
      vex::Gif gif("dance.gif", 120, 0 );
      
      for(int i = 0; i < 201; i++){
         Brain.Screen.printAt( 5, 230, "render %d", countgif++ );
         Brain.Screen.render(true, false);
        if(i > 199) {
          k = false;
          Brain.Screen.clearScreen();
          preAutonomous();
         }
      }
}

so this is my code (cropped), and it DOES read the if statement, because it does stop at 200 frames, and when i take

k = false

out of the code, it goes to 200, and then restarts the loop from 1. So it IS reading the code, but for some reason it is not clearing the screen or running the callback. Anyone know how i can fix this?