Remove duplicate and add newlines