Reading x Number of Records in a File

I am trying to attempt to write a program which reads a txt file.

The file starts with an int on the first line with nothing else. The rest of the file contains records of names (25 Characters long) followed by an amount of grades that correlates with the int from the first line (Meaning if the first line was 5, there would be five grades per record.) Each record contains spaces to separate the name and each grade. The program will go on to create two new txt files that sort the records by grade highest to lowest average minus the lowest grade and names alphabetically with the average minus the lowest grade.

I'm not sure exactly where to start my code. I understand the opening, reading, etc, but I'm a little confused on how to make my program understand the first line is the amount of grades there will be per record, and how to incorporate that to when I have to average the said amount of grades for each record.
Topic archived. No new replies allowed.