write_string called as class method returns empty string