Fixed copying of null terminator to wrong location