Inside your loop you're reading into $name instead of $studentname. I'm not sure how your sample output still manages to print the correct names, since your printf uses $studentname as well.
You're also forgetting about the line terminators. The first time you'll correctly read the name and scores. The second time your name will actually contain the line feed from the first line followed by the first 19 characters of the second name (or 18 if it's CR/LF instead of just CR)
For each subsequent line things will keep shifting. That's probably why you never find the "END".