Ctrl-Z works as you suggest in the code above, but it must be the first character on a line and must be followed by a newline (although other characters may intervene between the Ctrl-Z and the newline). A Ctrl-Z that is not the first character on a line shows up as a teeny, right-pointing arrow.