created general funtion with strings instead of file fointers