Fixed bug with end of file duplicates