def count_words(text):
    word_count = len(text.split())
    return word_count

def count_characters(text):
    char_count = len(text)
    return char_count

def count_lines(text):
    line_count = text.count('\n') + 1
    return line_count

def main():
    while True:
        try:
            user_input = input("Enter text or provide a file path (or 'exit' to quit): ")
            
            if user_input.lower() == 'exit':
                print("Exiting the program.")
                break
            
            if user_input.startswith("file:"):
                filename = user_input[5:]
                with open(filename, 'r') as file:
                    text = file.read()
            else:
                text = user_input
            
            words = count_words(text)
            characters = count_characters(text)
            lines = count_lines(text)
            
            print(f"Word count: {words}")
            print(f"Character count: {characters}")
            print(f"Line count: {lines}")
            
        except FileNotFoundError:
            print("File not found. Please enter a valid file path.")
        except Exception as e:
            print(f"An error occurred: {e}")

if __name__ == "__main__":
    main()
