Improve code that gets classification from news headlines and save on the file