We know from Gauss theorem that the electric field due to an infinietly long straight wire, at a perpendicular distance r from it equals,
So, the work done is
(where x is perpendicular distance from the thread by which point 1 is removed from it.)
Hence