Fix a small resource leak when writing file lists