buffer writes to file