def count_words_characters_lines(text):
    word_count = len(text.split())
    character_count = len(text)
    line_count = text.count('\n') + 1
    return word_count, character_count, line_count

def main():
    while True:
        print("===== Word, Character, and Line Counter =====")
        print("Enter '1' to input text manually.")
        print("Enter '2' to read text from a file.")
        print("Enter '0' to exit.")
        choice = input("Enter your choice: ")

        if choice == "0":
            print("Exiting the program.")
            break

        elif choice == "1":
            text = input("Enter the text: ")
            word_count, character_count, line_count = count_words_characters_lines(text)
            print("Word count:", word_count)
            print("Character count (including spaces):", character_count)
            print("Line count:", line_count)

        elif choice == "2":
            filename = input("Enter the file name: ")
            try:
                with open(filename, 'r') as file:
                    text = file.read()
                    word_count, character_count, line_count = count_words_characters_lines(text)
                    print("Word count:", word_count)
                    print("Character count (including spaces):", character_count)
                    print("Line count:", line_count)
            except FileNotFoundError:
                print("File not found. Please enter a valid file name.")

        else:
            print("Invalid input. Please try again.")

        print()

if __name__ == "__main__":
    main()