He forgot a verse whilst he was offering a naafil prayer, so he moved to pick up a Mushaf and opened it to remind himself of the verse
Question

                I was praying the two rakah sunnah salah after Maghrib. During the first ra'kah I was reciting a surah I just recently learned. Halfway through I forget a verse. I stayed there for about 2 minutes attempting to remember what the next verse was. When I couldn't remember, I moved forward to get a mushaf from the shelf in front of me. I read from the mushaf and then put it back. Is what I did permissible or is something to be avoided?.
Praise be to Allah.
      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? 

    He replied: 

    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.