Close the InputStream before replacing the body

This fixes a bug where the InputStream would not always get closed when full
logging is enabled.