tools: mkenvimage: Fix read() stdin error handling