Tweak rewritersample's output a bit (whitespace) and add a simple test.
Use namespace std explicitly.