Handled one case #2. Only unique ids get written.