Implemented 'write_bits'