Configuration screen

Blitz3D Forums/Blitz3D Beginners Area/Configuration screen

I am trying to add a configration options screen which will be a separate executable from the main game.
This program should read from a .DAT file, and overwrite it too allowing for the main program to use the data by reading it back.

However, when I test it, I have a problem with the first line of the DAT file.
For test purposes, I only use two lines:

first line = Integer value for GfxMode
second line = string$ for game difficulty

The string$ works [erfectly. The integer, however, once Written (with WriteInt) the .DAT file becomes somehow corrupted and instead of being a '1' or whatever, just shows null-characters (the little squares) and some tabs.

How can I prevent this?

my code is below:

config=ReadFile("Config.dat")

gfxmode=ReadLine(config)
difficulty$=ReadLine$(config)

CloseFile(config)
totalgfx=CountGfxModes()
Graphics GfxModeWidth(gfxmode),GfxModeHeight(gfxmode),GfxModeDepth(gfxmode),0
SetBuffer BackBuffer()
While Not KeyDown(1)
Cls
Text GraphicsWidth()/2,0,"Configuration Settings",1,0
Text GraphicsWidth()/2,30, "RESOLUTION (R): "+GfxModeWidth(gfxmode)+" x "+GfxModeHeight(gfxmode)+" Bit Depth:"+GfxModeDepth(gfxmode),1,0
If KeyDown(19) Then gfxmode=gfxmode+1
If gfxmode>totalgfx Then gfxmode=1
Text GraphicsWidth()/2,60, "DIFFICULTY LEVEL (D): "+Difficulty$,1,0
If KeyDown(32) Gosub DIFF_CHANGE
If KeyHit(19) Or KeyHit(32) Then Delay 250
Flip
Wend
EndGraphics
config=WriteFile ("config.dat")
WriteInt (config,gfxmode)
WriteString (config,difficulty$) 
CloseFile(config)
ExecFile "Turbo.exe"
.diff_change
If difficulty$="Easy" Then difficulty$="Normal" : Return
If difficulty$="Normal" Then difficulty$="Hard" : Return
If difficulty$="Hard" Then difficulty$="Very Hard" : Return
If difficulty$="Very Hard" Then difficulty$="Very Easy" : Return
If difficulty$="Very Easy" Then difficulty$="Easy" : Return


Apologies for messy code - it's still in test-phase :)