Added the -i option to do record by record rewrite