
Ick! I hate this problem...it drives me crazy.
In my building, we must be on-time to specials, recess, lunch, etc. So, often, going back to the room or sitting back down simply isn't an option. What I've started doing is that kids who are not "safe, straight, and silent" in line, have to walk behind me going down the hallway and be my shadow. (Sooooo embarrassing for them!) It also means that they are the last ones to get to go to lunch or recess or specials.
I have a zero tolerance policy - by now they know the expectations and shouldn't need a warning or reminder. So, the first instance of the day they leave the line and walk behind me on just that trip. If there is another instance that day, then they get to be my shadow for the rest of the day.
One other management tip is to train students to stop at corners as you walk down the hall. Then, as the class turns the corner YOU stay at the corner so that you can see/hear all students in the line. I've noticed that teachers who lead their lines often have chaos at the back when kids know they are out of sight.

Works like a charm...