file_put_contents some how did not work

<?php
if ($_POST['S1']=="")
{
header("Location:file_puts_contents.htm");
exit;
}
echo "reading existing file---<br/>";
$path1 ="test_put.txt";
$localfile = file_get_contents("test_put.txt");
echo "file size is: ".filesize($path1 ) . ' bytes';
echo "<br/>". $localfile;
?>
<html>
<title> file_puts_contents.php</title>
<body text="#000080" bgcolor="#F7F0D7">
reading the modified file <br>
<?php
$text = $_POST['S1'];
echo $text."<br>";
$file = "test_put.txt";
if(is_readable($path1))
{
echo ("$file is readable");
$path = fopen("test_put.txt","ab");
fwrite($path, "$text\r\n");
$mod = file_get_contents("test_put.txt");
echo "<br/> modified : $mod<br/>";
//file_put_contents($path,$text);
//echo "<br/> put : $fcont ");
fclose($path);
}
else
{
echo ("$file is not readable");
}
?>
</body>
</html>

the text source file