this program uses a different file called validate, which validates the inputed password and username. The input (from standard input) is in this form: file_name \n username \n password. But when I run my program (which forks a child and pipes the input to the child), stdin looks like this: file_name \n username \n password \n \n. Why does this happen, and how do I mitigate it?

int fds[2]; 
  if (pipe(fds) == -1) {
    return -1; 
  } 
  
  int n = fork(); 
  if (n == -1) {
    return -1;
  } else if (n == 0) {
    // child process
    close(fds[1]); // closed unused end 
    dup2(fds[0], STDOUT_FILENO);  
    execl("./validate", "validate", NULL); 
    close(fds[0]); 

  } else {
    // parent process
    close(fds[0]); 
    write(fds[1], user_id, 10); // hardcoded MAXPASSWORD
    write(fds[1], password, 10); 
    close(fds[1]);
    int status; 

    if(wait(&status) == -1) {
      return -1; 
    } else if (WIFEXITED(status)) { // checks id process exits normally 
      int validation = WEXITSTATUS(status); 
      if (validation == 0) {
        printf(SUCCESS); 
      } 
    }
  }

  return 0;