remove duplicate and print newline