Strip out trailing newlines and other crud.