Added trailing whitespace removal on write