The parentheses around the assignment expression (in red) are needed because assignment has lower precidence than !=.
while ( (ch = getchar()) != EOF )
Without the red parenthese, the statement would work as if it were written like this:
while ( ch = (getchar() != EOF) )
which would assign either a 0 (for false) or a 1 (for true) to ch.
Above is an example of the program working, with input from the keyboard and output to the monitor.
Could this program be used as it is with input from a text file and output to a text file?