Fixed global variable writing in append mode.