Fix segfault on docs without trailing newline