Small code style issue here -- the curly brace should be at the same level as the while. Or maybe there's a tab here.