Yes, I need it to run until stopped, which I have written an input sub function which changes the variable to 0 which should then stop it. but problem still remains that the loop never runs when its called and locks it up
Surely the question still remains, how do you know ...that the loop never runs... ? By ...it locks up..., I assume you mean the caller, aka the script, which if true, surely implies that the loop is indeed starting and as Corion and ikegami have both already pointed out, you (or more accurately, your script) is 'suffering' from buffering.
A user level that continues to overstate my experience :-))