All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
The prayer of that person is valid, and the prayer of the person who prays in a row alone behind the rows is also valid, although disliked. This is the view held by the majority of scholars, and it is the one adopted at Islamweb. The dislike is removed when there is a valid excuse. There is no doubt that leaving an empty space for the worshipers to enter the mosque is a valid excuse for standing in a row by yourself during the congregational prayer.
For more benefit, please refer to fatwa 31530.
Allah knows best.