added a check before fs.close 

fs.openSync() is done in a conditional block. There can be a case where destinationFileDesc is not present.
Added the check for that.