def fileIn = "FILENAME" def fileOut = "FILENAME" def input = new File(fileIn) def unique = new TreeSet() input.eachLine() { unique << it } def output = new File(fileOut) unique.each() { output.append(it + "\r\n") }