Fix write to output