added loop and fixed dos lineendings