improved portability using os module
improved how files are read