in reply to Spaces between outputs.
Normally I would comment that print "$i" should drop the useless quotation, but in your case, you only need to insert a space there: print " $i".