From what I understand, The extraction operator >>, by default, skips white spaces. Those lines will change that setting and take white spaces into consideration. This allows the program to output and input white spaces as if they were characters.
Replacing the extraction operator with .get() and also using .put(), I think that those lines can be deleted anyway.