Writing data in buffer