Move most file IO methods to separate file