This will likely be rather expensive. This is because the problem you describe seems like it would be hard to express as a shallow arithmetic circuit, which is a rough estimate of how difficult the computation is with FHE.
In particular, a naive algorithm for solving your problem is:
Instantiate some hashmap
Iterate through your textfile, when you see the ...