Whitespace trimming for cpp files

Added automatic trimming of trailing whitespace when writing
cpp files to disk.