I found your question not clear but if you want to execute something every 2 seconds you need to use a timer , the code you wrote just stop executing the code for 2 seconds.
and for more readable code use this
using (StreamWriter sw = new StreamWriter(path))
{
}
hope that i could help