I have tried using all the commands mention in Byte Commander's answer to the question here but they do not work unless the program finishes.
I am running a python script like so 'python script.py' and have tried replacing 'command' in Byte Commander's answer with 'python script.py' however the terminal output is not shown in the terminal anymore with any of the commands and only gets written to the file output.txt in the case that the python script completes (actually I've discovered it comes in large chunks as it proceeds, but not line-by-line as I require). I believe it may be because the python script calls another non-python program in another shell (it calls a finite element package called gmesh). The code takes a long time (several hours) to complete and I want to be able to see the output written to the file as it proceeds so I can see it's progress and what the terminal output looks like even if the program crashes part way through. How might I be able to go about this?
I've added a video to demonstrate the issue. When the program runs without capture the information comes line by line. When I attempt to capture the output it comes in chunks, when these chunks takes hours and it crashes during this process I get no information on where it crashed.