added back write check an made write data a char array