Changed to StringBuffer rather then stream for input