Simplified a checking.

std::isprint(char) returns true for the space character.

Therefore, if ch == ' ', then !std::isprint(ch) will be false and ch !=
' ' is useless.