add diags, use spew() instead of (now orphaned) write_file()