Sort and remove duplicate lines from a text file