Handle input stream