Use $fp = fopen($file, "r+"); PHP Manual would have told you this. Niklas -----Original Message----- From: Zenith [mailto:[EMAIL PROTECTED]] Sent: 22. elokuuta 2001 12:39 To: [EMAIL PROTECTED] Subject: [PHP] How can I insert the data into the begining of a text file I orginal have a function like the following... $fp = fopen ( $HTTP_SERVER_VARS['DOCUMENT_ROOT']."/log/debug_message.txt", "a" ); fputs ( $fp, "\nDebug message from : $PHP_SELF\n" ); fputs ( $fp, "\t$message\n\n" ); fclose ( $fp ); But I found that, the result is, all message is append to the end of a file. Can I insert the text into the begining of the file?? I think read all the text from the file first, arrang the string variable, so that the new message can insert, would be a solution. But is it stupid to do so?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]