added code to remove trailing blank lines