Improved file reading
python2 fix