Basic file writing

This has some issues because I'm not handling newlines properly when
inserting text.  It assumes each line is terminated with a newline,
which currently isn't always the case with inserted text.  Also,
inserted text may have a newline in the middle of the text.