Escape extra chars added at end of file