fixed trailing and leading \r\n probelms