fixed a defect when there are multiple erroneous spaces at the end of line