Smarter file reading