num_lines = sum(1 for line in open('./Infra/wikiniews_results.tsv')) file = open('num_lines.txt', 'w') file.write(str(num_lines)) file.close()