Created a thread to run in the background to check for inputstream