if you need to keep the header associated with the data records then I would create a temp file which appends each data record with the header record.
EX: 06-01-0301:00 1169 Usr1369***12556
Take the temp file and sort on the data record prtion of the record. read sorted record in to an array looking for a break on the data (if prior ne current){write array to a file}. There are a million other ways to do this and I'm sure many are more efficient. Hope this helps.