one way using CSV (comma-separated values) to build a string of 10 integers into a single line of data:
+ Code Snippet// Project: Data
// Created: 2022-08-15
// By: Virtual Nomad
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Data" )
SetWindowSize( 1280,720, 0 )
SetWindowAllowResize( 1 )
// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
GLOBAL Data as Integer [9,9]
GenerateData()
SaveData()
GenBUT = 1 : AddVirtualButton(GenBUT,1000,50,100) : SetVirtualButtonText(GenBUT,"GENERATE")
SaveBUT = 2 : AddVirtualButton(SaveBUT,1000,150,100) : SetVirtualButtonText(SaveBUT,"SAVE")
LoadBUT = 3 : AddVirtualButton(LoadBUT,1000,250,100) : SetVirtualButtonText(LoadBUT,"LOAD")
OpenBUT = 4 : AddVirtualButton(OpenBUT,1000,350,100) : SetVirtualButtonText(OpenBUT,"OPEN")
do
If GetRawKeyState(27) then End
If GetVirtualButtonPressed(GenBUT) then GenerateData()
If GetVirtualButtonPressed(SaveBUT) then SaveData()
If GetVirtualButtonPressed(LoadBUT) then LoadData()
If GetVirtualButtonPressed(OpenBUT) then OpenFile()
ShowData()
Sync()
loop
Function GenerateData() //fill 10x10 array with random integers
for y = 0 to 9
for x = 0 to 9
Data[x,y] = Random(0,1000)
next x
next y
EndFunction
Function SaveData() //save 1 row at a time with each # separated by a comma
ThisFile = OpenToWrite("data.dat")
for y = 0 to 9
ThisRow$ = ""
for x = 0 to 9
If x = 0
ThisRow$ = STR(Data[x,y])
Else
ThisRow$ = ThisRow$ + "," + STR(Data[x,y])
EndIf
next x
WriteLine(ThisFile,ThisRow$)
next y
CloseFile(ThisFile)
EndFunction
Function ShowData() //assemble each array row as a single string for print display
for y = 0 to 9
ThisRow$ = ""
for x = 0 to 9
If x = 0
ThisRow$ = STR(Data[x,y])
Else
ThisRow$ = ThisRow$ + "," + STR(Data[x,y])
EndIf
next x
Print(ThisRow$)
next y
EndFunction
Function LoadData() //read each row and assign integers separated by commas to appropriate data index
ThisFile = OpenToRead("data.dat")
for y = 0 to 9
ThisRow$ = ReadLine(ThisFile)
for x = 1 to CountStringTokens(ThisRow$,",") //could be 1-10 since we know we wrote 10 integers
Data[x-1,y] = VAL (GetStringToken(ThisRow$,",",x) ) //x-1 since array starts at 0
next x
next y
CloseFile(ThisFile)
EndFunction
Function OpenFile() //file was saved to write path
OpenBrowser(GetWritePath()+"/media/data.dat")
EndFunction
no idea what you're doing with the integers so i'm just feeding the data into a 10x10 array for demonstration purposes (extracting single values from each string):

have a play with it.
add: i just re-read the question and it seems you were opening a file, writing an integer, closing the file for every value that you wanted to write. with the code provided, it's obviously not required. just Open File, Write/Read everything, Close File.
then, again, i mis-read the question. if you want a single integer on each line, i could modify the code. just ask and sorry for assuming (and not having consumed enough coffee before going on this adventure)