Move writemd5() call outside unrelated try construct