Groovy script to get agent list against particular agent manager

I am looking for groovy script to get list of agentid against particular agent manager. The output from following command is text file, I need csv file. 

$FGLHOME/bin/fglcmd{.sh or .bat) -usr -pwd -cmd agent:list >> agentlist.txt