moved the fgets in the runloop to fix a bug