cleaner file reading code