libfstools: make sure file is closed on error