Edited Write function, Deleted extraneous lines and variables