Made load function open file using a with-statement