fixed missing null terminator in buffer chunks

Added null terminator to process I/O chunks using a buffer.
fixed string printing bug

Fixed bug where the 'str_nprintf' family of functions wrote the null byte too
early because the internal pointer was not advanced.