Fix segfault when saving blank document

Need to special-case this for automatic trailing newline insertion
algorithm.