If sync fails then close is never called. We should always be calling close on the file. Co-authored-by: Hendrik Appel <happel@europe.altair.com>