Fix resource leak in handling of Training Files