Replaced AutoCloseable interface with Closeable to make the code
compatible with Java 7