add 'r' to regular expressions
implicit close of outfile with 'with' block