Rewrite that loop like so:
PHP Code:
$found false;
$fp fopen(...);
while(
$fp && ($tmpecho fgets($fp1024))) {
  if(
strpos($tmpecho"Building configuration...") !== false) {
    
$found true;
    break;
  }

This breaks the loop if the file is bad or simply reached the end.