Updated file reading function (maybe a bit faster?)