Fix for #814, Memory Leak

File isn't closed before being released, it leaks. This test has been verified and tested many times.