Quote:
My program works perfectly for smaller files. Is there any way to make my code better?
If you don't want magic answers, the first thing to do is to understand how the program spend time and why.
The tool of choice is the
profiler.
Profiling (computer programming) - Wikipedia[
^]
Once you see which part of code consume time, you can use the
debugger to see how.
By the way, how many words aree up to 1000 chars ? or 500 ? or 100 ? or even 50 chars?
words of size 1000 is only a waste of resources.