How to prompt user to download a file?
Have you tried the http://drupal.org/project/file_force Module ?
Some details from the module's project page:

File Force Download can be used to force the user's web browser to download the file to disk instead of displaying it in the browser window.
Web browsers today are pre-configured to render various types of media directly, such as text files, various image, video and audio formats, PDF documents, and Flash movies. While it is still possible to save such files afterwards by right-clicking on them and selecting &quot;Save As..&quot;, it is sometimes desirable to just offer the file for download in the first place. File Force Download solves this issue by supplying a file with certain HTTP headers which instruct the web browser to download the file to the user's disk instead of displaying it in a browser window.

It should be a good starting point for inspiration for your own module.