updated output thread to use a bufio scanner