A simple solution would be using a variable containing
current state as either
- Processing a valid word.
- Processing blanks.
- Processing a to-be-skipped word.
Then, based on current state and next char, your program could establish correctly what to do.