Got single file mode working. More tests need to be done (edge cases need to be handled).