Help me in solving PPSC270 problem

My issue

Its difficult so I want answer

My code

#include <stdio.h>

void userFunction() {
    // Initialise the character pointers and open the respective files
    char *inputfilename = "/home/codechef/input.txt";
    char *outputfilename = "/home/codechef/output.txt";
    
    FILE *inputfile = fopen(inputfilename, "r");
    FILE *outputfile = fopen(outputfilename, "w");

    // Check if files opened successfully
    if (inputfile == NULL || outputfile == NULL) {
        printf("Error opening files.\n");
        return;
    }

    int number;

    // Read and write the numbers from the input file to the output file
    while (fscanf(inputfile, "%d", &number) != EOF) {
        fprintf(outputfile, "%d\n", number);
    }

    // Close the input and output files
    fclose(inputfile);
    fclose(outputfile);

    // Display the contents of output.txt
    outputfile = fopen(outputfilename, "r");
    if (outputfile == NULL) {
        printf("Error opening output file for reading.\n");
        return;
    }

    printf("Contents of output.txt:\n");
    while (fscanf(outputfile, "%d", &number) != EOF) {
        printf("%d\n", number);
    }

    fclose(outputfile);
}

Learning course: Programming and Problem solving using C
Problem Link: https://www.codechef.com/learn/course/ciet-programming-c/CIETPC37/problems/PPSC270