File being created without form submit

Howdy! I’ve been working on a form to create a file with a form in it. I successfully written the code to test the file and the form are created. The issue is that the file is being created when the page loads not when the form is submitted. Any pointers would be appreciated
Here is the form that is supposed to generate the file with a form.

<?php error_reporting(E_ALL); ?>
<form action="" method="post">
<label for="add_header_text_opt">Add Header Option</label>
<input type="checkbox" name="add_header_text_opt" value="Yes" />
<p><input type="submit" name="submit" value="Create Options" class="button" /></p>
</form>

Here is the code that is supposed to be activated by the form but is processed when the file is opened.

<?php
if(isset($_POST['submit']) && isset($_POST['add_header_text_opt']) && $_POST['add_header_text_opt'] = "Yes") {
$test_file_create = "testFile.php";
$mk_test_file = fopen($test_file_create, 'w'); 
if($mk_test_file == false) {
die("can't open file");
}
else {
$mk_settings_form = '<form name="settings_form action=" method="post">'."\
".'<label>mylabel</label></form>';
fwrite($mk_test_file, $mk_settings_form);
//test and form created
echo file_get_contents($test_file_create);
}
fclose($mk_test_file);
}
?>

Thanks again

you have a missing curly bracket in your 2nd block of code.