Change indenting to 4 spaces and add error handling for Unicode encoding