[BUGFIX] Close file handle only if unused in FileWriter