Fix inconsistent whitespace, and add a close call in the main method to avoid a resource-leak warning