branch: use write_file_buf instead of write_file