Fixes crash when reading output in some cases