Finished implementing file I/O, added test for that

Also refactored another FM-index function