Can't get touch position in variable?

I am new in unity trying to get touch position but having error this line:

Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);

here is my code:

using UnityEngine;
using System.Collections;

public class enemy : MonoBehaviour {
// Update is called once per frame
void Update () {
	Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
	Vector2 touchPos = new Vector2(wp.x, wp.y);
	transform.position = touchPos;
    }
}

Error: Index out of bounds.

Firstly check if there are any touches before you access the Touches array.

So the code becomes:

public class enemy : MonoBehaviour {
// Update is called once per frame
void Update () {
    if(Input.touchCount > 0) {
        Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
        Vector2 touchPos = new Vector2(wp.x, wp.y);
        transform.position = touchPos;
    }
    }
}