To prepend text, you simple need to read the file, and then write what you want, followed by the original file data.
For more information, see the wiki Searching the Forum for Answers section.