add backspace. use puts replace write to shorten code.