added C style bate writing