Ok for my Programming II class there is an assigment that is supposed to pull a list of scores from a file and calculate them in output back to the user. There should be a prompt that asks for the file (an error message if there is no file). The program then uses the list of numbers and calculates the total score at the end.

To start off though I need help with the following code specifically in the "// Read N, how many numbers " part.
Code:
#include <stdio.h>

#include <stdlib.h>

 

int main()

{

// Declare file pointer

FILE *ifp;

int N, i, x;

char fname[50];

 

printf("Enter filename: ");

scanf("%s", fname);

printf("Opening %s\n", fname);

 

// Open file

ifp = fopen(fname, "r");

if (ifp == NULL)

{

  printf("Error, %s not available\n", fname);

  exit(1);

}

 

// Read N, how many numbers

fscanf( ifp, "%d", &N);

printf("How many is %d\n", N);


// Read the values from the file 

 for (i = 0; i < N; ++i)

{

   fscanf(ifp, "%d", &x);

   printf("%d: %d\n", i, x);

}

return 0;
-----
In the output the program only prints 4 of the numbers in the file being opened in the program. Any advice?