I found this problem writing simple pascal programs:
When saved source code gets a filename without extension the source file has the the same name as the compiled file.
After compiling the source file is gone, but you can work on without problems - before next compile the source file overwrites the compiled file, then the compiled file overwrites the source file again, etc.
But when geany is closed, the source code isn't stored in memory anymore. Next time when it's opend you see the beginning of the compiled binary file.
One (easy) solution could be forcing a language specific extension to sourcefiles then there can't be files without extensions.
Another (better) solution could be testing wheter the source file has no extension and using a different name for the compiled file.
Sorry if I used bad English.