Added saving functionality and fixed newlines.