I'm using a code that allows users to add a message to a text file, the message shows in a image but at the end of every message theres a character that isn't supposed to be there (I think its because the code makes a new line for every new message). Does anyone know how to fix? If not then can someone tell me how to make it split messages using | instead of a new line?

This is the code that lets people add a message:-


PHP Code:
<?php

if (isset($newmsg)) { 
// go through the proccess of checking, and possibly adding a new  message

$file "messages.txt";      // message file
$fd fopen($file"a+");
$wordarray file($file);


$newmsg stripslashes($newmsg);
$newmsg strip_tags($newmsg);

if (!
in_array($newmsg."\r\n",$wordarray,TRUE)) { // word not already there

if (!$newmsg=="") { // don't accept empty message
    
fputs($fd,$newmsg."\r\n");
    echo(
"<h4>The message \"$newmsg\" has been added!</h4>");

// Now the logging, for people who use this to insult others.

$ip=$_SERVER['REMOTE_ADDR'];   // Get IP
$date=date('h:i:s A | D | F dS'); // Get date

// Below is the path and what to put in log.htm

$logtxt="<html><body bgcolor=black><tt><font color=red>$ip</font> <font color=blue>| $date | </font> <font color=white> $newmsg</font></font></tt><BR><hr><BR>";
$fp=fopen("addlog.htm""a+");   // Open addlog.htm  
fwrite($fp$logtxt); // Write to addlog.htm
fclose($fp);  // Close addlog.htm

    
}
else {
    echo 
"<h4>You cannot enter a blank message!</h4>";
    }

}
else {
    echo(
"<h4>The message \"$newmsg\" already exists!</h4>");
    }

fclose ($fd);


//end of add new message process
}
?>

<BR><BR><Br><Br><Br>


        <form METHOD="GET" name="NewMessage" action="add.php">
<?php

echo"
    <input type='hidden' name='list' value='no'>
    <font size='6' face='Verdana, Arial, Helvetica, sans-serif'> Type a message in the box below and it'll be added to the signature.
    <br>
    <input type='text' name='newmsg' size='50'>
    <input type='submit' name='Submit' value='Submit'>
    </font> 
    </form>"
;
?>
And the code that grabs a message:-

PHP Code:
$file "messages.txt"// Messages in here
$fd fopen($file"r"); // Open the file for read only
$words file($file);  // Put each word in an array
fclose ($fd);
$word_number rand(1,count($words)); // Show a random message on the image
$word $words[$word_number-1]; // Position in array is $word_number-1
$word ereg_replace("\n"""$word);