use write_file_buf where applicable