Pulling output from sh bgp summ

I have tried to pull the output from bgpout.txt(attached) with “idle” and hostname of the router to another file bgpsumactive.txt(attached) .
I was partially successful and could not able to get the hostname of the router to bgpsumactive.txt … Any leads will be helpfull.

Note : Since I couldn’t upload .txt file I have uploaded it in .jpg file

Hello,

I couldn’t understand your problem. Can you be more specific or put your code?