in reply to Re Replacing duplicate string
in thread Replacing duplicate string

Here's some pseudocode to help you get started:
while (readline into $line) if $line starts with 'priority' print $line if 'priority not already seen' remember that priority was seen end else if $line is blank forget that priority was seen end else print $line end end

while (readline into $line) if $line starts with 'priority' replace 'priority' with 'bandwidth' if 'priority already seen' remember that priority was seen end else if $line is blank forget that priority was seen end print $line end

It's basically what Corion already said, but it has the basic structure of what your code might look like. Now all you have to do is translate it.

Update: Changed pseudocode to do substitution rather than skip printing.