It sounds like reading the file probably is ignorable.

The slowest (and most CPU intensive) parts are likely to be the text manipulations and nested loops, and there are various ways that they could potentially be improved based on what they do, and how well optimised they are already.

The loops will probably be the easiest to improve, as they are unlikely to require changes to the rest of the code.


In terms of hogging the CPU, one way to avoid that (which will probably slow the program down) is to move the code to a timer - but I would recommend leaving that until after you have optimised the code a bit.


If you want help with optimising, show us a section of code that is a bottleneck at the moment (which the profiler will probably make clear to you).