''Example:'' Avoiding an INPUT mode or [[INPUT (file statement)|INPUT #]] read error using a FileExist function. QB64 can use the [[_FILEEXISTS]] function.
{{CodeStart}} '' ''
DIM Fdata$(100)
INPUT "Enter data file name: ", datafile$
IF FileExist%(datafile$) THEN
D% = {{Cl|FREEFILE}}: count = 0
{{Cl|OPEN}} datafile$ FOR {{Cl|INPUT (file mode)|INPUT}} AS #D%
IF count = 100 THEN {{Cl|EXIT}} DO ' don't exceed {{Cl|Arrays|array}} size!
LOOP
{{Cl|CLOSE}} #D%
ELSE : PRINT "File not found!"
END IF
{{Cl|FUNCTION}} FileExist% (filename$)
f% = {{Cl|FREEFILE}}
{{Cl|OPEN}} filename$ FOR {{Cl|APPEND}} AS #f% ' check that file exists
IF {{Cl|LOF}}(f%) THEN FileExist% = -1 {{Cl|ELSE}} {{Cl|CLOSE}} #f%: {{Cl|KILL}} filename$
{{Cl|CLOSE}} #f%
{{Cl|END FUNCTION}} '' ''
{{CodeEnd}}
: ''Explanation:'' The function opens the filename in [[APPEND]] mode to see if there is data in the file. It also creates the file if it did not exist. [[LOF]] will return 0 if the file is empty and cannot be read. In fact you can [[KILL]] the file if it is empty. If it is not empty then the function returns -1 and the existing file can be opened for INPUT and read by the program. [[_FILEEXISTS]] doesn't create any files.