Take out extra buf.write()