Not all subjects being printed

Can someone take a look at this script please? It’s purpose is to gather, for
each user the tickets he or she worked on for each customer. The problem I’m
having is that for some reason or another, the subject isn’t being written for
all of them. It prints out some but, randomly skips others. At least, randomly
as far as I can tell. I don’t see any particular issue that would cause this
behaviour and have verified that the format is proper.

So if anyone can take a look and see if they find anything that might be choking
this up I’d appreciate it.

Keep up with me and what I’m up to: (6.64 KB)