Replaced standard for with foreach in toString method.