`length-2`? Is it `\r\n`? Comment should be updated, and you could also allocate the string only once.