fix defect, add '\0' to output string