fix write file bug and add loadGrams bug