PHP - Difficulties Writing New Line : <p>I am encountering difficulties with writing to a new line in a basic text file. All the other text (including the comma) appears just fine, but no new line (no space or anything either). I would greatly appreciate any direction.</p>

<pre><code>&lt;?php 
session_start();
$user = $_SESSION['store'];

function format($input) {
$input = trim($input);
$input = stripcslashes($input);
$input = htmlspecialchars($input);
return $input;

}

$file = "messages/reminder.txt";
$image;
$secFreqLabel;
$freqLabel;
$uploadDirectory = "corpImages/";

if(!file_exists($file)) {
$temp = fopen($file, "w"); // create file
fclose($temp);
}

 $con = new PDO("sqlite:bk.db");
if($_SERVER['REQUEST_METHOD'] == "POST") {
$secFreqLabel =  'reminder.jpg';
$freqLabel =  'reminderHourly.jpg';
$thirdFreqLabel =  'reminderThree.jpg';
$fourthFreqLabel =  'reminderFour.jpg';

$freqUploadFile = $uploadDirectory . $freqLabel;
$secFreqUploadFile = $uploadDirectory . $secFreqLabel;
$thirdFreqUploadFile = $uploadDirectory . $thirdFreqLabel;
$fourthFreqUploadFile = $uploadDirectory . $fourthFreqLabel;

$statement = $con-&gt;prepare("INSERT INTO slides (image, label) VALUES (:image, :label)");

if(!empty($_FILES['freqImage'])) {
$con-&gt;exec("DELETE FROM slides where label = 'reminder.jpg'");
}

if(!empty($_FILES['secFreqImage'])) {
$con-&gt;exec("DELETE FROM slides where label = 'reminderHourly.jpg'");
}

if(!empty($_FILES['thirdFreqImage'])) {
$con-&gt;exec("DELETE FROM slides where label = 'reminderThree.jpg'");
}

if(!empty($_FILES['fourthFreqImage'])) {
$con-&gt;exec("DELETE FROM slides where label = 'reminderFour.jpg'");
}

$image = file_get_contents($_FILES['freqImage']['tmp_name']);
move_uploaded_file($_FILES['freqImage']['tmp_name'], $freqUploadFile);
$statement-&gt;bindParam(":label", $freqLabel);
$statement-&gt;bindParam(":image", $image);
$statement-&gt;execute();

$image = file_get_contents($_FILES['secFreqImage']['tmp_name']);
move_uploaded_file($_FILES['secFreqImage']['tmp_name'], $secFreqUploadFile);
$statement-&gt;bindParam(":label", $secFreqLabel);
$statement-&gt;bindParam(":image", $image);
$statement-&gt;execute();

$image = file_get_contents($_FILES['thirdFreqImage']['tmp_name']);
move_uploaded_file($_FILES['thirdFreqImage']['tmp_name'], $thirdFreqUploadFile);
$statement-&gt;bindParam(":label", $thirdFreqLabel);
$statement-&gt;bindParam(":image", $image);
$statement-&gt;execute();

$image = file_get_contents($_FILES['fourthFreqImage']['tmp_name']);
move_uploaded_file($_FILES['fourthFreqImage']['tmp_name'], $fourthFreqUploadFile);
$statement-&gt;bindParam(":label", $fourthFreqLabel);
$statement-&gt;bindParam(":image", $image);
$statement-&gt;execute();

$text = format($_POST['freq']) . "," . format($_POST['freqMessage']) . "\n" . format($_POST['secFreq']) . "," . format($_POST['secFreqMessage']) . "\n" . format($_POST['thirdFreq']) . "," . format($_POST['thirdFreqMessage']) . "\n" . format($_POST['fourthFreq']) . "," . format($_POST['fourthFreqMessage']);

$writer = fopen($file, "w");
fwrite($writer, $text);
fclose($writer);

touch("update.txt");
}

$handler = fopen($file, "r");

$firstReminder = fgetcsv($handler, ",");
$secondReminder = fgetcsv($handler, ",");
$thirdReminder = fgetcsv($handler, ",");
$fourthReminder = fgetcsv($handler, ",");
fclose($handler);


?&gt;
</code></pre>
