Every court in dealing with a child who is brought before it as an offender shall have regard to the welfare of the child and shall in a proper case take steps for removing him from undesirable surroundings.