#!/usr/bin/env python3 """Simple word counter - counts words in a text file.""" import sys def count_words(filepath): """Count words in a file and return the total.""" with open(filepath, 'r') as f: text = f.read() return len(text.split()) if __name__ == '__main__': if len(sys.argv) != 2: print("Usage: word-counter.py ") sys.exit(1) print(count_words(sys.argv[1]))