" and line 717 is whitespace. if (strpos($lines[715], '') !== false && trim($lines[716]) === '') { $lines[715] = str_repeat(' ', 48) . ')}'; $lines[716] = str_repeat(' ', 44) . ''; echo "Successfully replaced lines!\n"; } else { echo "Line content mismatch!\n"; echo "Line 716: [" . $lines[715] . "]\n"; echo "Line 717: [" . $lines[716] . "]\n"; } file_put_contents($file, implode("\r\n", $lines));