rewriting text files