Do you know why this one is a better approach to have a better success at detecting duplicates?
Also, there is a line which puts the pointer at the beginning of the file. Isn't by default an initialization of a stream to have its pointer at the beginning of the file?