Fix problem with null terminator at the end of a string