corrects a bug when dataDir does not end with '/'.
This replaces dir+file with os.path.join(dir, file) everywhere. This way, it does not crash if dir does not end with '/' character (which is the standard way to specify a directory). Tested with a successful simulation.