Answered by Shaykh Faraz Rabbani
What is the ruling concerning the imam ensuring that the lines behind him are straight? Must he ensure all the lines (if few in #) are straight? Is there anything that is mustahab for the imam to say to the congregation to advise them to straighten the lines before starting? If you have the arabic or can offer a transliteration I would appreciate it.

Walaikum assalam wa rahmatullahi wa barakatuh,
It is from the sunna for the imam to specifically ensure that the lines are straight–reminding the followers when necessary to do so. The Messenger of Allah (peace and blessings be upon him) said, “Straighten your lines, for doing so is from proper establishing of prayer.” [Bukhari (723) and Muslim (433), from Anas]
It is from the sunna for the followers to stand straight, shoulder to shoulder, and not to leave gaps between themselves.
[ Tahtawi/Shurunbulali, Hashiyat Maraqi al-Falah; Ibn Abidin, Radd al-Muhtar; Binnori, Sharh al-Tirmidhi ]
It would appear that this is best done before the iqama itself is given–because it is best for the prayer to begin immediately upon the iqama, in the Hanafi school.
And Allah alone gives success.
Faraz Rabbani
قوله صلى الله عليه وسلم : (سَوُّوا صُفُوفَكُمْ فَإِنَّ تَسْوِيَةَ الصُّفُوفِ مِنْ إِقَامَةِ الصَّلَاةِ ) رواه البخاري (723) ومسلم (433) من حديث أنس رضي الله عنه .