Yes, $wrap only returns one line at a time. You need to loop through $wrap(.....,N) where that will return the Nth line. N = 0 returns number of lines