Valmiki Ramayana Kishkindha Kanda Sarga 12 Shloka 20
Original Shlokaयन्नावगच्छत्सुग्रीवं वालिनं वापि राघवः। ततो न कृतवान्बुद्धिं मोक्तुमन्तकरं शरम्4.12.20।।
1 source checked for this shloka
राघवः Rama, सुग्रीवम् Sugriva, वालिनं वापि or Vali, यत् such and such, नावगच्छत् not able to distinguish, ततः then, अन्तकरम् deadly, शरम् arrow, मोक्तुम् to discharge, बुद्धिम् intellect, न कृतवान् not made.
Since Rama was not able to distinguish between Vali and Sugriva, he could not decide whether he should discharge his deadly arrow .