Updating, making code neater.

Still need to fix the bug where it isn't writing anything - however, there are no errors (i.e python closing) when running the program now, which is good.