open txt from Blender only works sometimes

This piece of code works in my script if i open my blend file by double clicking it. If I however load the file from within blender (open or recent) it does not find the text files, placed in a folder ‘logFiles’.
I’m not to good with python. What am I missing here?


objs = ['wheel_fl', 'wheel_fr', 'wheel_rl', 'wheel_rr']
logDir = 'logFiles/'
logFormat = '_log.txt'
for currObj in objs:
        if os.path.exists(logDir+currObj+logFormat):
            file = open(logDir+currObj+logFormat, "r")
        else:
            raise IOError('Failed reading file: '+logDir+currObj+logFormat)

You should try an absolute path