Bug fix for ctl.conf generator.

Ticket: #5244

Before this change only the first portal ip was getting
listed in the config file.

(cherry picked from commit f9284a3270c29c6cd70b979b6b108e20432ac78a)