It is preferred for the imam to order the followers to straighten the rows and fill in any gaps before he starts the Prayer. Elaborating more on this issue, we cite what Sheikh Sayyed Sabiq states in his well-known book, Fiqh Us-Sunnah: It is preferred for the imam to order the followers to straighten the rows and fill in any gaps before he starts the Prayer.
Anas relates: The Prophet (peace and blessings be upon him) would turn his face to us before he began the Prayer and he would say, “Be close together and straighten your rows” (Al-Bukhari and Muslim). He also reported that the Prophet would say, “Make your rows straight, for the straightening of the rows is part of the completion of the Prayer.”
An-Nu`man ibn Bashir says: The Prophet would straighten us in our rows as one straightens an arrow, until he saw that we had learned from him. One day, he saw a person with his chest sticking out and he said, “You had better straighten your rows or Allah will cause differences among you.”
Abu Umamah reports that the Prophet (peace and blessings be upon him) said, “Straighten your rows and put your shoulders close to each other and be gentle with each other and fill in the gaps, for the Shaytan passes through what is between you like small sheep [are able to pass through gaps]” (Ahmad and At-Tabarani). Anas reports that the Messenger of Allah said, “Complete the front row, then the ones after it, and if there is any incompletion, it should be in the last row” (Abu Dawud, An-Nasa’i, and Al-Bayhaqi). Ibn `Umar says, “There is no step that carries a greater reward than the step a man takes to an empty gap in a row in order to fill it.” Ibn `Umar also related that the Messenger of Allah said, “Whoever connects a row, Allah will join him. Whoever cuts off a row, Allah will cut him off” (An-Nasa’i, Al-Hakim, and Ibn Khuzaimah).
Jabir ibn Samrah said: The Prophet (peace and blessings be upon him) came to us and said, “Why don’t you make the rows like the angels make their rows in the presence of their Lord?” We asked, “O Messenger of Allah, how do the angels make their rows in the presence of their Lord?” He replied, “They complete the first row and stand closely together, side by side, in the row” (reported by the group except Al-Bukhari and At-Tirmidhi).