fixed string.sub bug, remove \r\n from the end of string