Trying to implement input stream