handle stdin buffer