fix bug in the loop of parsing files