Introduced file i/o

Still buggy and causes a crash on exit