Improved robustness of GetLLM

Does not crash if you run only with either linx or liny file. Writing
files are extracted into a finally block. 'higher_order' functions are
not crashing if only linx or liny file is given.