If condition inside Job not working

Permalink
I don't even have a clue why this is happening. The if condition in my job is not working properly. I triple checked the $flag variable and it is true. Still the code always goes to the else condition.
$flag = file_exists($csvFile);
if($flag){
     //A big chunk of code
} else {
     return 'Whatever you do I will always go here XD';
}


I hard coded true inside if, it works properly. Then another if inside that chunk of code also always goes to else. Again double checked Express. Express object exists and object is returned properly.

$flag = file_exists($csvFile);
if(true){
     //Some code here
     $entity = Express::getObjectByHandle('user');
     if(is_object($entity)){ 
          // Another chunk of code
     } else {
          return 'You cant escape from me that easily... XD';
     }
     //some code here
} else {
     return "Now I'm a good boy";
}