Fixed bug when saving in text mode