Add a final eol character when writing files

if the file being overwritten has one. This makes things more friendly
for vim users.
Merge branch 'respect_final_eol_preference'