I seem to not understand the phenomenon of writing something to output which relies on the input, BEFORE getting the input. Either that, or you need something like threads? One for writing the output based on previous calculations that include the last input and another for getting the input whenever you need it.