Close the standard input right after reading to avoid duplicate calls

Change-Id: Idd4b5bf996d57f0cd22a30496af3841f7d5a806a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>