inData.get(ch);
while(ch != '#') {
newPart += ch;
}
Say you read in 'h' for the first char. How many times does that loop execute?
Back to this part then. My point is not that you shouldn't have that while loop but that what you do inside it has to be changed. That loop is an infinite loop given your input. It will read in the first char 'h', and since it doesn't equal '#', it adds it to the variable newPart, but then the loop goes back up and checks the condition, and since ch hasn't changed, it still doesn't equal '#', so it adds 'h' to newPart again, and it will do that an infinite amount of times because you never change ch inside the loop. You have to change it to read in the next char in the loop.
You can't just move the read statement into the loop either:
Code:
while(ch != '#')
{
inData.get(ch);
newPart += ch;
}
because when you hit the EOF, you're going to have problems with it repeating the last char. So, you need to do something like this:
Code:
inData.get(ch);
while(ch != '#')
{
newPart += ch;
inData.get(ch)
}