correct check when writing } and fixed writing number at correct offset