Safeguard on process.stdin.read()

When stdin is produced by a slow process, process.stdin.read()
may return null.

Add a check to avoid a crash when getting null