delimLen didn't count in null-terminator. On line 62 the null terminator character doesn't get copied.