Make sure to delete the file object on close (from Alja Tadel).