Added fclose for file handle which was left open