Moving during the prayer is makrooh unless it is done out of necessity.
We have previously discussed the kinds of movements during the prayer and the rulings of them in the answer the question no. 12683.
The movement that you described is a small movement and was done in the interests of the prayer, so there is nothing wrong with it. It was one of the movements that are permitted whilst praying.
Shaykh Ibn âUthaymeen (may Allah have mercy on him) was asked:
If a person is offering a naafil prayer and he is reciting lengthy soorahs and forgets some of the verses, and there is a Mushaf in front of him, can he pick up the Mushaf in order to check what he missed in his recitation, or should he stop where he cannot carry on reciting, and bow?
There is nothing wrong with either option, so long as he is offering a naafil prayer on his own. If he gets confused about a verse and the Mushaf is nearby, there is nothing wrong with him picking it up and looking, because this is for a need that has to do with the prayer. And there is nothing wrong with stopping his recitation and bowing, because sometimes if he bows he will remember the verses that he forgot. So there is nothing wrong with bowing then remembering them, because this is what he wanted. And if he cannot remember them, then he should recite whatever he can manage. End quote.
Liqaâ al-Baab al-Maftooh, 83/18
It should be noted that the Sunnah in the regular Sunnah prayer of Maghrib is to recite Qul ya ayyuhaâl-kaafiroon in the first rakâah and Qul Huwa Allahu Ahad in the second, as is proven from the Messenger (blessings and peace of Allah be upon him). Narrated by al-Tirmidhi (431); classed as saheeh by al-Albaani in Saheeh al-Tirmidhi.
And Allah knows best.