You didn't really explain your problem, you just said your code wasn't working. It looks fine to me, apart from you should have a line checking if the file exists, so that you can delete it and save it, or else db will come up with an error message saying the file exists. You should also check if it exists before the loading, or else you will be trying to load a non existant file.
Here is a small demo on how to use these commands (source box)...
cuRant PRogekt: a three-de map editer
Why the hell'd you ask me for crying out loud!?!
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM