Remove trailing white spaces
Close IO (Fix #8087)

Patched by pypypy567. Thanks!!!