fix detection of end of command with new line.