Arduino is freezing after running function twice

Okay so the problem was that my write function itself was a String

Rubbish. Functions and classes are completely different beasts. The return type of the function was a String, and you WERE told to get rid of ALL Strings.