fgets e lidar com entrada CTRL + D

Eu estou pegando alguma entrada padrão do usuário e se o usuário pressionaCTRL + D, Quero exibir um erro e finalizar o programa. Acho que talvez o meu problema esteja relacionado a estar preso em um loop while;

int readInput(){
   char buff[10];
   int count = 0;
   int counter;
   printf("Enter random number: ");
   fgets(buff, 10, stdin);
   if ((int) strtol(buff, NULL, 10) == 0){
      printf("Error reading number. \n");
      return 0;   //This will get hit if the user presses CTRL+D at this input.
   }
   counter = atol(buff);
   while (count < counter){ 
      printf("Enter a label: ");
      fgets(buff, 10, stdin);
      if ((int) strtol(buff, NULL, 10) == 0){
         printf("Error reading label");
         return 0;  //This will not get hit if the user presses CTRL+D at this input, but why?
         //I've also tried assigning a variable to 0, breaking out of the loop using break; and returning the variable at the end of the function but that also does not work.

      //the rest of the while loop continues even if user hit CTRL+D
      printf("Enter Value: " );
      fgets(buff, 10, stdin);
      //..rest of while loop just gets other inputs like above
      count++;
   }

//termination happens in main, if readInput returns a 0 we call RETURN EXIT_FAILURE;

Eu não entendo porque na primeira entrada se o usuário pressionaCTRL + D, o programa responde de acordo, mas na segunda vez o ignora completamente.

questionAnswers(1)

yourAnswerToTheQuestion