Dinisimys1, всеравно из файла title всё копируется, весь файл записывается в title тэг

Вот код:
<?
echo '<html>
<head>
<title>
New page
</title>
</head>
<body>
<p>';
if (empty($_POST['macros'])){
echo '<form action="index.php" method="POST">
<input type="text" name="macros"><br>
<input type="submit" value="Create">
</form>';
}else{
$pagename = $_POST['macros'];
$t_file=explode(" ",file_get_contents('title.txt'));
$nt=mt_rand(0,sizeof($t_file));
$title=$t_file[$nt];
$ka_file=explode(" ",file_get_contents('kontent.txt'));
$nka=mt_rand(0,sizeof($ka_file));
$nkb=mt_rand(0,sizeof($kb_file));
$nkc=mt_rand(0,sizeof($kc_file));
$ka=$ka_file[$nka];
$kb=$kb_file[$nkb];
$kc=$kc_file[$nkc];
$foot=file_get_contents('foot.txt');
$html='<html>
<head>
<title>'.$title.
'</title>
</head>
<body><div class="a">'.$ka.'</div>
<div class="b">'.$kb.'</div>
<div class="c">'.$kc.'</div>
<div class="c">'.$foot.'</div>
</body>
</html>';
$name=$pagename.'.html';
$f_html=fopen($name,'w');
fwrite($f_html,$html);
fclose($f_html);
$f_links=fopen('links.txt','a');
$links='<a href="'.$name.'">'.$name.'</a><br>\n\r';
fwrite($f_links,$links);
fclose($f_links);
}
?>