cleaned up variable file writing