File loading algorithem

File loading now works.