Fix `write_file` for freebsd