optimized writing spaces

Note: this code is untested, I just wrote it here on github without even launching gmod. You're gonna want to test it to make sure it works