Fixes file reading bugs