Using the each-line combinator to output each line of text that is not identical to the previous line (using f to force the first line to always be printed):

:uniq-lines(--)f [ 2dup = [ dup print ] unless nip] each-line drop ;

The input is optionally specified, so need a uniq-file word that will "uniq" the lines of a file, or read directly from the current input-stream (which will be standard input when run from the command line):