Creating a Linked LIst from a File ERRORS!

I need to read in instructions from a file, then with those instructions, insert the names and scores below the instruction into a linked lists. I've tried using getline, and >> and I keep getting errors. Here is what I have so far:

I'm working on this program in steps, and when I output the values I just put in for the %INSERT function, I get %PRINT in a loop.
My program also skips over the first line of the file. It doesn't recognize it.
The File is:
%INSERT
MARK 29
DAVID 21
JOHN 44
JOHN 51
LARRY 39
MARK 21
DAVID 18
JOHN 28
MARK 35
DONALD 41
PHIL 26
%PRINT
%DELETE
MARK
DAVID
%PRINT
%SEARCH
JONE
DAVID
LARRY
%INSERT
LARRY 13
GARY 15
GARY 42
%PRINT
%INSERT
TERRY 23
%DELETE
GARFIELD
%SEARCH
PHIL
%PRINT
%END

This looks like an infinite loop. You establish at first that input is %INSERT, and then you keep reading in for as long as input does not equal %DELETE, but you never change input, so it will always be %INSERT and the while loop will never end.

This looks like an infinite loop. You establish at first that input is %INSERT, and then you keep reading in for as long as input does not equal %DELETE, but you never change input, so it will always be %INSERT and the while loop will never end.

So how do I continue reading in a new input and still get the names and scores from the file?
I tried this:

>>So how do I continue reading in a new input and still get the names and scores from the file?

Read the file line by line using getline.
Look at the fist char of the line read in.
If it's an '%' the line is an instruction so find the instruction and do what needs to be done per implementation of that instruction
If not, its a name and beak the line up into the name and the number using a stringstream. You can then use the name to search or delete or change the information in the node, whatever.

>>So how do I continue reading in a new input and still get the names and scores from the file?

Read the file line by line using getline.
Look at the fist char of the line read in.
If it's an '%' the line is an instruction so find the instruction and do what needs to be done per implementation of that instruction
If not, its a name and beak the line up into the name and the number using a stringstream. You can then use the name to search or delete or change the information in the node, whatever.

I thought about that first but once the program reads the instruction, it needs to continue reading in the names and scores so that it can insert them, delete them, etc in the linked list.

Not a problem. The program could be basically one big loop with a loop in each subroutine that needs it so it can read in more than one line if needed:

bool keepRunning = true
string temp;
read in first line to temp
while keepRunning
if temp is %insert
read next line into temp
while first char of temp is not %
use stringtream to break temp up and create new node
insert node into list
read next line into temp
else if temp is %search
read next line into temp
while first char of temp is not %
use stringtream to break temp up
use another loop to search list for node with information from temp
if information in temp found
do something
read next line into temp
...
else if temp is %EXIT
change keepRunning to false

You will need to expand the if/else if statements to include all instruction options. You may want to use other types of loops depending on your comfort level. Etc. But this type of schematic should work.