There is 2 option you can do.
You can configure VTY Lines to discussonect automatically if they are idle 5min, so you do not required this script
line vty 0 4
exec-timeout 5 0
Other option is you need to store the output of VTY lines and disconnect only meet the requirement, Line by Line, more Lines of code required.
example :
2 vty 1 cisco idle 5w1d 192.168.11.4
* 3 vty 2 cisco idle 00:00:18 192.168.11.14
5 vty 4 cisco idle 00:00:09 192.168.11.15