removes trailing whitespace and adds newline to end of files