I let the script run overnight, and woke up to a 1.2GB text file and the script still running. Lots of incorrect dupes, so I'm going to need to track down why that happened.

My experience with awk is pretty limited, so this is a chance to learn it a bit more.