Use hash-style function arguments in write_default_fields()
Change a comment line
Extract read_tmpfile()
Remove unnecessary quotes around "attachment"