Replaced echos to files with printf's that actually seem to work. The echos weren't working sometimes.