Reading Writing of patterns works

Fixed lots of bugs.
Read - works
Write - works * needs to re load file after write