Fixes for txt file writing and reading

Text file function fixes and reading and plot adaptions.