I think it would be better if you replace this for loop with "join" function from string class.