You can do that by first reading the contents of the file and then adding the new post at the begin of the file content, in the end save it.
I wouldn't do that, I would more suggest you to read the file into an array, line by line or preg_ functions.
After you have the array you look here for a sorting function that suits your needs.
I'll post a script in few mins, I'm busy right now!
EDIT:
When you save the posts, you can use bbCodes,
You would save this as single line into your file, then you can use the preg_replace function to sort the data.
Take a look here for the preg_replace
http://www.supportforums.net/showthread.php?tid=1676
I wouldn't do that, I would more suggest you to read the file into an array, line by line or preg_ functions.
After you have the array you look here for a sorting function that suits your needs.
I'll post a script in few mins, I'm busy right now!
EDIT:
When you save the posts, you can use bbCodes,
Code:
[poster]Motu[/poster][date]24.12.2009 01:39 AM[/date][post]Something[/post]
You would save this as single line into your file, then you can use the preg_replace function to sort the data.
Take a look here for the preg_replace
http://www.supportforums.net/showthread.php?tid=1676