removing tabs and replacing with spaces, adding newline an the end of buffer and removing trailing spaces