Fixed problem of input task being stuck when input stream stops: