Removed unneeded fflush
Addressed memory leak.