rewrite text file