How to remove duplicate lines from csv or txt file? The answer is quite straightforward: you basically need BufferedReader and BufferedWriter, and this also works for large files quite well.