Fix notices on undefined $fileHandle and $res

Change-Id: If9f37549af85df0a418dbd12a7793e5a45868f61