Almost right. sort -u will give one copy of each input record whether it was unique or not to begin with. What he wants is uniq -u and uniq -D since he stated the input was already sorted. My program below does it in one pass, though.
Comment on Re: Re: Separate duplicate and unique records
Well, sort -u (or simply the default behavior of uniq) matches the behavior of the OP's sample code -- that is, it prints all values once, but only once. Perhaps that is not what he wanted, but if he stated that in his original post, it's not clear to me. Either way, it seems he has many solutions to any number of problems, some of which may be the actual problem he was looking for help with. :)