algorithm is working but I can't find a way to read STDIN