refactor method saveFile in Parser.java