fix encoding issue with file rewriting util