Code was checking wrong return code from a piped command.

Changed code to check return code of first command in the pipe.

Change-Id: I4d8a034e50281854a7aa565e2bfcc604d64227e0