That's complicated - and I'll ignore your code since it won't even compile, let alone do anything useful.
Why is it complicated? Because text files don't have "lines" - they can contain "end of line" characters line '\n' but that is just interpreted as a line end character when you read the file. Which means if you try to write a number at the beginning of the file, then you have to plan ahead, because if the new number has more or less digits than the existing one, you have to rewrite the entire file to keep it working!
You code is muddled - you are appending data to you file, yes - but you have a loop which overwrites the value you are going to write so only the last value will be added, but you loop through all the rows to get there! I'd strongly suggest you sit down and think about what you are trying to do before you go any further.
What I'd do (apart from use a "real" database instead which is probably some weeks away in your course) is copy from the old file to a new file, writing your new "header" information first, then delete the old file, and rename the new. Also ave a look at the File class:
File Class (System.IO) | Microsoft Docs[
^] with particular reference to the ReadAllLines and WriteAllLines methods - they will make your code a lot "cleaner".