let rec remove_trailing_whitespaces_end str =
if String.length str > 0 &&
(str.[String.length str - 1] = '\n'
|| str.[String.length str - 1] = ' '
|| str.[String.length str - 1] = '\t') then
remove_trailing_whitespaces_end (String.sub str 0 (String.length str - 1))
else str