Fix bounds check on output window search pattern